博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ios中scrollView基本用法
阅读量:4604 次
发布时间:2019-06-09

本文共 1264 字,大约阅读时间需要 4 分钟。

设置scrollView内容的尺寸(滚动的范围)      self.scrollView.contentSize = CGSizeMake(892, 480);      self.scrollView.contentSize = self.minionView.image.size;      self.scrollView.contentSize = self.minionView.frame.size; // 总体内容的范围(滚动范围)    // <#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>    //外边距(用于穿透效果等)    self.scrollView.contentInset = UIEdgeInsetsMake(10, 20, 40, 80);
- (IBAction)scroll {      [UIView animateWithDuration:1.0 animations:^{          self.scrollView.contentOffset = CGPointMake(100, 0);      }];    //    CGPoint offset = CGPointMake(-100, -100);    CGPoint offset = self.scrollView.contentOffset;    offset.x += 10;    offset.y += 10;    [self.scrollView setContentOffset:offset animated:YES];}

 

- (void)viewDidLoad{    [super viewDidLoad];        // 设置内容尺寸//    CGFloat contentH = self.lastBtn.frame.origin.y + self.lastBtn.frame.size.height+ 10;    // 10是底部的间距    CGFloat contentH = CGRectGetMaxY(self.lastBtn.frame) + 10;    self.scrollView.contentSize = CGSizeMake(0, contentH);        // 增加额外的滚动区域(在顶部增加64的区域,在底部增加44的区域)    self.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 44, 0);        // 设置一开始的滚动位置(往下滚动64)    self.scrollView.contentOffset = CGPointMake(0, -64);}

 

转载于:https://www.cnblogs.com/zqrios/p/7421908.html

你可能感兴趣的文章
WCF 中,出现The remote server returned an unexpected response: (400) Bad Request.
查看>>
缓存概要
查看>>
vue项目中使用百度地图的方法
查看>>
[Vue-rx] Stream an API using RxJS into a Vue.js Template
查看>>
[Javascript] lodash: memoize() to improve the profermence
查看>>
手写符合Promise/A+规范的Promise
查看>>
Python time和datetime模块
查看>>
JPA、JTA、XA相关索引
查看>>
查询语句的练习
查看>>
快速切题 sgu103. Traffic Lights 最短路 难度:1
查看>>
2010年5月11日日志
查看>>
产品需求文档(PRD)的写作
查看>>
网页高度计算方法
查看>>
Java EE的map
查看>>
webdriver.py--解说
查看>>
windows 下配置Eclipse che
查看>>
SearchSploit
查看>>
2017.3.2
查看>>
关于C语言中的转义字符
查看>>
9-条件测试
查看>>