//当contentSize的高度大于scrollView的superView的height的时候,才会滚动 //设置滚动视的内容 self.scrollView.contentSize = CGSizeMake(0, 1500); //设置间距 self.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0); //设置起点 self.scrollView.contentOffset = CGPointMake(0, -64); //当contentInset设置在contentSize的前面的时候,会自动调整contentOffset //设置间距 self.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0); //设置滚动视的内容 self.scrollView.contentSize = CGSizeMake(0, 1500); //也可以直接在scrollView懒加载中添加 -(void)setScrollView:(UIScrollView *)scrollView { _scrollView = scrollView; self.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0); self.scrollView.contentSize = CGSizeMake(0, 1500); }
//1.不显示水平垂直标示 self.scrollView.showsHorizontalScrollIndicator = NO; self.scrollView.showsVerticalScrollIndicator = NO; //2.弹簧效果 self.scrollView.bounces = NO; //3.放大缩小倍数 self.scrollView.maximumZoomScale = 2.0; self.scrollView.minimumZoomScale = 0.2; #pragma mark - UIScrollViewDelegate //需要放大缩小的view - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; }
原文:http://my.oschina.net/u/2346786/blog/507089