1.設置scrollView的滾動範圍
self.scrollView.contentSize = CGSizeMake(self.iconView.frame.size.width , self.iconView.frame.size.height);
// 2.設置偏移量
// self.scrollView.contentOffset = CGPointMake(200, 200);
// 3.增長scrollView上下左右的滾動範圍
self.scrollView.contentInset = UIEdgeInsetsMake(100, 50, 30, 70);
電臺
// 1.設置滾動範圍
CGFloat maxY = CGRectGetMaxY(self.lastBtn.frame);
self.scrollView.contentSize = CGSizeMake(0, maxY);
// 2.設置偏移量
self.scrollView.contentOffset = CGPointMake(0, -64);
// 3.設置額外滾動的範圍
self.scrollView.contentInset = UIEdgeInsetsMake(64, 0, 44, 0);
用來監聽到scrollView開始滾動調用
*
* @param scrollView <#scrollView description#>
*/
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
NSLog(@"我開始拖拽");
}
/**
* 表示拖動scrollView過程
*
* @param scrollView <#scrollView description#>
*/
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"%f",scrollView.contentOffset.x);
}
/**
* 結束拖拽
*
* @param scrollView <#scrollView description#>
* @param decelerate <#decelerate description#>
*/
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
NSLog(@"結束拖拽");
}
@property (weak, nonatomic) IBOutlet UIImageView *iconView; //鏈接按鈕
**
* 告訴咱們捏合縮放哪一個控件
*/
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.iconView;
}