你的位置:首页 > 软件开发 > 操作系统 > 简单的图片无限轮播器(要点提醒)

简单的图片无限轮播器(要点提醒)

发布时间:2016-04-22 21:00:09
1 #import "ViewController.h" 2 #define kDeviceWidth [UIScreen mainScreen].bounds.size.width 3 #define kDeviceHeight [UIScreen main ...
 1 #import "ViewController.h" 2 #define kDeviceWidth [UIScreen mainScreen].bounds.size.width 3 #define kDeviceHeight [UIScreen mainScreen].bounds.size.height 4 #define  Kpage 3 5 @interface ViewController ()<UIScrollViewDelegate> 6  7 @property(nonatomic,strong)UIPageControl *pageCtrl; 8 @property (nonatomic,weak) UIScrollView *scrollView; 9 @property (nonatomic,weak) UIImageView *currentImageView; // 当前imageView 10 @property (nonatomic,weak) UIImageView *nextImageView; // 下一个imageView 11 @property (nonatomic,weak) UIImageView *preImageView; //上一个imageView 12 @property (nonatomic,assign) BOOL isDragging; // 是否正在滚动 13 @property (nonatomic,strong)NSTimer *timer; 14 @end 15  16 @implementation ViewController 17  18 - (void)viewDidLoad { 19   [super viewDidLoad]; 35   //  初始化当前视图1.当前图片2秒后(假如定时器2秒执行一次)移动到640(定时器每执行一次移动一个屏幕宽度);进入if (offset == scrollView.bounds.size.width * 2) 判断2.判断结果为当前页面的图片换成前面next的图片,结果为img2,next的图片为空,current当前页面位置变成320(i= 2)3.因为next的图片为空,所以进入if (self.nextImageView.image == nil || self.preImageView.image == nil) 
4.判断结果,根据后面的三目运算next的图片换成img3(因为三目运算)5.当前图片2秒后又(定时器2秒执行一次)又移动到640(定时器每执行一次移动一个屏幕宽度);进入if (offset == scrollView.bounds.size.width * 2) 判断把图片换成img3,让next为空,从此无限循环

源文件在这里:http://pan.baidu.com/s/1kVKrbkb


 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:简单的图片无限轮播器(要点提醒)

关键词:图片

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。