self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO;
self.scrollView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
self.scrollView.bounces = YES/NO;
self.scrollView.alwaysBounceVertical = YES;
self.scrollView.alwaysBounceHorizontal = YES;
self.scrollView.contentInset = UIEdgeInsetsMake(10, 20, 30, 40);
- -(void)scrollViewWillBeginDragging:(nonnull UIScrollView *)scrollView
- -(void)scrollViewDidEndDragging:(nonnull UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
- -(void)scrollViewDidEndDecelerating:(nonnull UIScrollView *)scrollView
+注意:如果想在UIScrollView停止滚动之后做一些操作, 有两种情况
+ scrollViewDidEndDragging
+ scrollViewDidEndDecelerating
- -(nullable UIView *)viewForZoomingInScrollView:(nonnull UIScrollView *)scrollView
self.sc.maximumZoomScale = 2.0; 最大2.0
self.sc.minimumZoomScale = 0.5; 最小0.5
-(void)scrollViewDidZoom:(nonnull UIScrollView *)scrollView
-(void)scrollViewDidEndZooming:(nonnull UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale
UipageControl
@PRoperty(nonatomic) NSInteger numberOfPages; 设置最大页数
// default is 0
@property(nonatomic) NSInteger currentPage;
设置页码
// 通过KVC给UIPageControl的私有属性赋值, 设置自定义图片
[self.pageControl setValue:[UIImage imageNamed:@"current"] forKeyPath:@"_currentPageImage"];
[self.pageControl setValue:[UIImage imageNamed:@"other"] forKeyPath:@"_pageImage"];
NSTimer
// 注意:NSTimer应该是weak
// 为什么NSTimer应该是weak, 因为只要创建一个NSTimer对象, 该对象就会被主线程强引用
@property (weak, nonatomic) NSTimer *timer;
// scheduledTimerWithTimeInterval: 创建一个定时器, 并且立即可是计时
// TimeInterval: 间隔时间
// target: 调用谁的方法
// selector: 调用什么方法
// userInfo: 需要传递什么参数
// repeats: 是否重复
// 每隔2.0秒调用一次self的nextPage方法, 并且不传递任何参数
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextPage) userInfo:nil repeats:YES];
// 主线程在处理其它事件的时候, 分一点时间来处理NSTimer
[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
// 只要调用invalidate方法, 系统就会将NSTimer从主线程移除, 并且销毁NSTimer对象
[self.timer invalidate];