UIScrollViewDelegate 方法调用
/** 设置缩放的View, 初始化完之后调用此方法告诉scrollView 谁可以缩放操作, 然后进行布局 */
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
print("viewForZoomingInScrollView")
return imageView
}
/** 缩放进行中调用 */
func scrollViewDidZoom(scrollView: UIScrollView) {
print("scrollViewDidZoom")
centerScrollViewContents()
}
/** 缩放开始调用 */
func scrollViewWillBeginZooming(scrollView: UIScrollView, withView view: UIView?) {
print("scrollViewWillBeginZooming")
}
/** 缩放结束调用 */
func scrollViewDidEndZooming(scrollView: UIScrollView, withView view: UIView?, atScale scale: CGFloat) {
print("scrollViewDidEndZooming")
}
/** 改变 offset调用: 缩放, 拖拽都会改变offset */
func scrollViewDidScroll(scrollView: UIScrollView) {
print(scrollView.contentOffset)
print("scrollViewDidScroll")
}
/** 开始拖拽调用 */
func scrollViewWillBeginDragging(scrollView: UIScrollView){
print("scrollViewWillBeginDragging")
}
/** 即将结束拖拽调用 */
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>){
print("scrollViewWillEndDragging")
}
/** 结束拖拽调用 decelerate: 是否在减速*/
func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool){
print("scrollViewDidEndDragging")
}
/** 开始降速调用 */
func scrollViewWillBeginDecelerating(scrollView: UIScrollView){
print("scrollViewWillBeginDecelerating")
}
/** 拖拽动画即将停止调用 */
func scrollViewDidEndDecelerating(scrollView: UIScrollView){
print("scrollViewDidEndDecelerating")
}
/** 当用代码设置scrollRectToVisible/ setContentOffset 时候调用 (注意 后面的animated 一定要传true, 否则不会触发)*/
func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView){
print("scrollViewDidEndScrollingAnimation")
}
/** 当点击(collectionView/ tableView y值滚动到某个位置)状态栏时候调用 */
func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool{
print("scrollViewShouldScrollToTop")
return true
}
/** 点击状态栏回到顶部调用 */
func scrollViewDidScrollToTop(scrollView: UIScrollView) {
print("scrollViewDidScrollToTop")
}