scrollview背景
生活随笔
收集整理的這篇文章主要介紹了
scrollview背景
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
當scrollview不設置背景色時,拖動scrollview上的內容,邊界顯示view的背景色。
當scrollview設置背景色時,拖動scrollview上的內容,邊界顯示scrollview的背景色
用兩種顏色時,可以在scrollview上再添加一層,如黃色的view。
?
滑動屬性:
_scrollView.pagingEnabled = YES; //只能按頁滑動,設置為NO時可以連續滑動
?? _scrollView.bounces = YES; //可以打開頂部的間隔,松開后,又彈回去了。 如果bounds設置為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 代表 禁止垂直方向滾動_scrollView.scrollEnabled = YES;_scrollView.pagingEnabled = YES;_scrollView.delegate = self;}IOS開發: 為UIImageView添加點擊事件
?
轉載于:https://www.cnblogs.com/dqxu/p/4024921.html
總結
以上是生活随笔為你收集整理的scrollview背景的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言中的static 详细分析
- 下一篇: Android屏幕适应详解(一)