UIScrollView在游戏项目中用的是很多的,但是具体有哪些属性呢,在这里我也做一个总结
UIScrollView *scr = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];//初始化一个scr scr.contentSize = CGSizeMake(self.view.frame.size.width * 2, self.view.frame.size.height *2);//设置scr可以滑动的区域 默认为0 ,也就是没有可以滚动区域 //下面的时一些属性 scr.contentOffset = CGPointMake(1024, 0); //最开始显示Scrollview的时候,让scrollview那一块内容出来。具体的可以参照http://blog.csdn.net/kylinbl/article/details/7043936 scr.contentInset = UIEdgeInsetsMake(100, 100, 100, 100); //刚加载的时候,显示的是哪一块内容 scr.showsHorizontalScrollIndicator = YES; //是否显示水平方向的滚动条 默认为 yes scr.showsVerticalScrollIndicator = YES; //是否显示垂直方向滚动条 默认为yes [scr setPagingEnabled:YES]; //滚动时是否直接滚动一个scr大小的距离 默认为 no scr.scrollEnabled = YES; //是否让scr可以滚动 默认为 yes scr.bounces = YES; //是否划到边界的时候有反弹效果, 默认为yes scr.bouncesZoom = YES; //有没有反弹效果,用在缩放上,在放大或缩小到最值时,是否与反弹效果 默认为yes scr.maximumZoomScale = 2.0f; //缩放的时候最大值 默认为1 scr.minimumZoomScale = 1.0f; //缩放的最小值 默认为 1 scr.clipsToBounds = NO; //超出范围的时候是否裁剪 默认为no scr.directionalLockEnabled = YES; //默认为no 可以随手势滚动,如果为yes 假如一开始是垂直或者是水平运动,就会锁定另外一个方向的滚动, 假如一开始是对角方向滚动,则不会禁止某个方向 scr.indicatorStyle = UIScrollViewIndicatorStyleWhite; //滚动涛的样式 只有三种 white black 和 默认(Default) // scr setScrollIndicatorInsets:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>) //设置滚动条的位置 scr.useInteractionEnable = YES; //视图对触摸事件是否需要作处回应 如果设置为NO,可以阻止视图接收和分发触摸事件
整体属性介绍 可参照http://blog.sina.com.cn/s/blog_992910ad0101441g.html
额外介绍一些Scrollview的东西,scrollview的属性实在是太强大了,点击按钮跳转scrollview的另外一屏的时候,有动画效果的代码
mainScr setContentOffset:<#(CGPoint)#> animated:<#(BOOL)#>
属性不定时更新····
scrollView.userInteractionEnabled = YES; //视图对触摸事件是否需要作处回应可以通过设置视图的userInteractionEnabled属性。
默认状态为YES,如果设置为NO,可以阻止视图接收和分发触摸事件