UIScrollView
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; }