标签:
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??:
进击的UI-------------------UIScrollView&UIPageControl
标签:
原文地址:http://www.cnblogs.com/sharkHZ/p/4984123.html