设置scrollView内容的尺寸(滚动的范围)
self.scrollView.contentSize = CGSizeMake(, );
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(, , , );
- (IBAction)scroll {
[UIView animateWithDuration:1.0 animations:^{
self.scrollView.contentOffset = CGPointMake(, );
}]; // CGPoint offset = CGPointMake(-100, -100);
CGPoint offset = self.scrollView.contentOffset;
offset.x += ;
offset.y += ;
[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) + ;
self.scrollView.contentSize = CGSizeMake(, contentH); // 增加额外的滚动区域(在顶部增加64的区域,在底部增加44的区域)
self.scrollView.contentInset = UIEdgeInsetsMake(, , , ); // 设置一开始的滚动位置(往下滚动64)
self.scrollView.contentOffset = CGPointMake(, -);
}