仿微博列表gif图片动态循环播放,浏览图片大图的简单框架

DJPhotoBrowser是一个简单的图片浏览器,适用于无限循环展示图片,尤其是gif动图。它模仿了微博信息列表中的gif动态效果,支持图片的弹出、隐藏动画、双击缩放、手势缩放、图片存储、网络加载gif和长图,以及横竖屏切换。适用于iOS 8.0及更高版本,使用Xcode 8.0以上进行开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DJPhotoBrowser

DJPhotoBrowser是一个简单的图片浏览器,可以无限循环展示图片,并制作了九宫格图片展示.
模仿微博信息列表动态循环展示gif动图.

  • 支持图片弹出和隐藏动画。
    -- Support the show and hide animation effects
  • 支持图片无限循环展示。
    -- Support infinite scroll to show photos.
  • 支持双击缩放,手势缩放,可设置缩放比例。
    -- Supports double-click scaling, gestures to zoom in.
  • 支持图片存储。
    -- Support photo storage.
  • 支持网络加载gif图片,长图滚动浏览。
    -- Support network loading GIF images, scroll through long figure.
  • 支持横竖屏显示。
    -- Support for landscape and vertical screen display switch.

Screenshots

九宫格图片展示
image

图片缩放移动
image

模仿微博 动态循环展示gif动图
image

Requirements

  • iOS 8.0 or later
  • Xcode 8.0 or later

Installation

  1. You should copy all the files in path 'DJPhotoBrowser' to your projects;

  2. Add under lines to your class:

#import "DJPhotoBrowser.h"
#import "DJPhotoGridView.h"
  1. Need SDWebImage

Licenses

All source code is licensed under the MIT License.

Architecture

DJPhotoBrowser

  • DJPhotoBrowser
  • DJPhotoBrowserView
  • DJWaitingView

DJPhotoGridView

  • DJPhotoGridView
  • DJPhotoItem

Usage

注意,如果使用SDWebImage下载图片请自行添加以下代码

// 如果想要新版本SDWebImage支持gif动画显示,需要加载GIFCoder
[[SDWebImageCodersManager sharedInstance] addCoder:[SDWebImageGIFCoder sharedCoder]];

DJPhotoBrowser

DJPhotoBrowser *browser = [[DJPhotoBrowser alloc] init];
// 原图的父控件,用于显示隐藏图片动画展示,也可通过dataSource设置
browser.sourceImagesContainerView = self;
browser.dataSource = self;
browser.delegate = self;
// 无限滚动,请在showWithImageCount前设置,代码未完善,如果后置设置会出错误并不支持重新设置
browser.infiniteScrollView = YES;
[browser showWithImageCount:self.photoItemArray.count imageIndex:button.tag];
DJPhotoBrowserDataSource
// 预览图片
- (UIImage *)photoBrowser:(DJPhotoBrowser *)browser placeholderImageForIndex:(NSUInteger)index;

// 原图片控件映射到PhotoBrowser的坐标,需要在delegate中做convertRect
- (CGRect)photoBrowser:(DJPhotoBrowser *)browser containerViewRectAtIndex:(NSUInteger)index;

// 高清图片URL
- (NSURL *)photoBrowser:(DJPhotoBrowser *)browser highQualityImageURLForIndex:(NSUInteger)index;
DJPhotoBrowserDelegate
// 图片滚动
- (void)photoBrowser:(DJPhotoBrowser *)browser didScrollToIndex:(NSUInteger)index;

DJPhotoGridView

DJPhotoGridView *photoGroup = [[DJPhotoGridView alloc] init];
photoGroup.frame = CGRectMake(10, 10, 100, 100);
photoGroup.tag = 100;
[cell.contentView addSubview:photoGroup];

photoGroup.photoItemArray = [self.tableDataArray objectAtIndex:indexPath.row];
photoGridViewSizeWith
// DJPhotoGridView高度计算
+ (CGSize)photoGridViewSizeWith:(NSArray<DJPhotoItem *> *)photoItemArray;

Author

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值