码迷,mamicode.com
首页 > 其他好文 > 详细

进击的UI-------------------UIScrollView&UIPageControl

时间:2015-11-21 18:33:47      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!