1.UIScroLLView基本
1⃣️:初始
self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(100, 100,200, 400)];
self.scrollView.backgroundColor = [UIColor whiteColor];
2⃣️:contentSize
self.scrollView.contentSize = CGSizeMake(300, 600);
3⃣️:偏移差
self.scrollView.contentOffset = CGPointMake(-20, -20);
4⃣️:可以滚回顶点
self.scrollView.scrollsToTop = YES;
5⃣️:能否整屏滚动
self.scrollView.pagingEnabled = YES;
6⃣️:能否滚动
self.scrollView.scrollEnabled = YES;
7⃣️:边界是否回弹
self.scrollView.bounces = YES;
8⃣️:水平方向
①:显示self.scrollView.showsHorizontalScrollIndicator = NO;
②:遇到边框是否回弹self.scrollView.alwaysBounceHorizontal = YES;
9⃣️:垂直方向
①:显示self.scrollView.showsVerticalScrollIndicator = NO;
②:遇到边框是否回弹self.scrollView.alwaysBounceVertical = YES;
🔟:缩放
①:指定最大和最大缩放和最小缩放的倍数
self.scrollView.minimumZoomScale = 0.5;
self.scrollView.maximumZoomScale = 2;
②:设置变化比例
 self.scrollView.zoomScale = 1.0;
③:缩放时是否会反弹
self.scrollView.bouncesZoom = YES;
2.UIScroLLViewDelegate
三部
1⃣️:设置代理
@interface RootViewController ()<UIScrollViewDelegate>
2⃣️:代理指向
self.rv.scrollView.delegate = self;
3⃣️:代理方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"我已经滚了!!");
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"我将要脱了!!");
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"我已将脱完了!!");
}
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    NSLog(@"我将要减速了!!");
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"我已经减速完了!!");
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale{
    NSLog(@"我已经完成了缩放!!");
}
// 缩小后不能拖
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
    return scrollView.subviews[0];
}
3.UIPageControl基本
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];(当前圆点颜色)
pageControl.pageIndicatorTintColor = [UIColor grayColor];(圆点颜色)
 
1⃣️:初始
self.pc = [[UIPageControl alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.frame), CGRectGetMaxY(self.frame) - 50, CGRectGetWidth(self.frame) ,  50)] ;
self.pc.backgroundColor = [UIColor blackColor];
 [self addSubview:_pc];
2⃣️:页面数
self.pc.numberOfPages = 3;
3⃣️:当前页
self.pc.currentPage = 1;
4⃣️:事件
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.rv.pc addTarget:self action:@selector(pcAction:) forControlEvents:UIControlEventValueChanged];
}
- (void)pcAction:(UIPageControl *)sender{
    NSLog(@"变了,这是当前页!");
}
4.UIPageControl与UIScrollView结合
 
1⃣️:
2⃣️:
3⃣️:
4⃣️:
posted on 2015-11-21 17:02  sharkHZ  阅读(92)  评论(0编辑  收藏  举报