scrollview背景
生活随笔
收集整理的這篇文章主要介紹了
scrollview背景
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
當(dāng)scrollview不設(shè)置背景色時(shí),拖動(dòng)scrollview上的內(nèi)容,邊界顯示view的背景色。
當(dāng)scrollview設(shè)置背景色時(shí),拖動(dòng)scrollview上的內(nèi)容,邊界顯示scrollview的背景色
用兩種顏色時(shí),可以在scrollview上再添加一層,如黃色的view。
?
滑動(dòng)屬性:
_scrollView.pagingEnabled = YES; //只能按頁滑動(dòng),設(shè)置為NO時(shí)可以連續(xù)滑動(dòng)
?? _scrollView.bounces = YES; //可以打開頂部的間隔,松開后,又彈回去了。 如果bounds設(shè)置為NO,則打不開下拉刷新
?
?
- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.//CGFloat w = self.view.frame.size.width;//CGFloat h = self.view.frame.size.height;int w = self.view.bounds.size.width;int h = self.view.bounds.size.height;self.view.backgroundColor = [UIColor redColor];_scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];_scrollView.backgroundColor = [UIColor blueColor];[self.view addSubview:_scrollView];UIView *view = [[UIView alloc]initWithFrame:self.view.frame];[_scrollView addSubview: view];view.backgroundColor = [UIColor yellowColor];for(int i = 0;i< kCount;i++){NSString *name = [NSString stringWithFormat:@"%02d.jpg",i+1];UILabel *label = [[UILabel alloc] init];label.frame = CGRectMake(i*w, 0, w, h);label.text = name;[view addSubview:label];}_scrollView.userInteractionEnabled = YES;_scrollView.contentSize = CGSizeMake(kCount*w, 800);// height == 0 代表 禁止垂直方向滾動(dòng)_scrollView.scrollEnabled = YES;_scrollView.pagingEnabled = YES;_scrollView.delegate = self;}IOS開發(fā): 為UIImageView添加點(diǎn)擊事件
?
轉(zhuǎn)載于:https://www.cnblogs.com/dqxu/p/4024921.html
總結(jié)
以上是生活随笔為你收集整理的scrollview背景的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言中的static 详细分析
- 下一篇: [openmp]使用嵌套互斥锁锁定变量