您的位置:首页 > 产品设计 > UI/UE

UIScroll和UIpageControl

2015-08-31 22:21 295 查看
<span style="font-size:18px;">//    UIScrollView
self.scroll = [[UIScrollView alloc]initWithFrame:self.frame];
_scroll.backgroundColor = [UIColor cyanColor];
[self addSubview:_scroll];

//如果想左右滑动,contentSize的宽一定要比scroll的frame的宽大,同理,上下滑动,contentSize的高的一定要比scroll的高大
//contentSize的宽一般是屏幕的宽的整数倍
self.scroll.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 4, 0);

self.imv = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"小黄人1.png"]];
self.imv.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width * 4, [UIScreen mainScreen].bounds.size.height);
[_scroll addSubview:_imv];

//pagingEnabled:是否允许整页滑动
self.scroll.pagingEnabled = YES;

//bounces:是否允许边框回弹效果
_scroll.bounces = YES;

//showsHorizontalScrollIndicator: 水平是否显示水平方向的滚动条
_scroll.showsHorizontalScrollIndicator = NO;

//alwaysBounceHorizontal:alwaysBounceHorizontal不可以控制水平方向的回弹效果 ,控制水平方向的回弹效果用bounces
_scroll.alwaysBounceHorizontal = NO;

//alwaysBounceVertical:alwaysBounceVertical可以控制垂直方向上的回弹效果
_scroll.alwaysBounceVertical = NO;

//showsVerticalScrollIndicator:是否显示垂直方向的滚动条
_scroll.showsVerticalScrollIndicator = NO;

//contentOffset:偏移量(是以左上角的点为基点的)
_scroll.contentOffset = CGPointMake(400, 0);

//minimumZoomScale:设置最小的缩放比例
_scroll.minimumZoomScale = 0.5;

//maximumZoomScale:设置最大的缩放比例
_scroll.maximumZoomScale = 2.0;

//UIPageControl
_page = [[UIPageControl alloc]initWithFrame:CGRectMake(50, 50, 200, 30)];

self.page.backgroundColor = [UIColor blackColor];

//numberOfPages:表示有几个小圆点
_page.numberOfPages = 8;
_page.pageIndicatorTintColor = [UIColor redColor];
_page.currentPageIndicatorTintColor = [UIColor greenColor];

//记录当前的页数
//    _page.currentPage;

//    [self.page addTarget:self action:@selector(pageAction) forControlEvents:UIControlEventValueChanged];</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: