标签:dism efault getc ima bool role lld 触摸 led
UIScrollView必须知道它的contentsize
这就是为啥TableView的row的height必须被计算,即使那些row还没有出现在屏幕。
The scroll view must know the size of the content view so it knows when to stop scrolling; by default, it “bounces” back when scrolling exceeds the bounds of the content
为了确定用户是在点击还是在滑动,UIScrollView自己维护了一个计时器,并记录手指的位置。如果计时器相应之前,还没有比较显著的移动,那么UIScrollView就发送触摸时间到相应的subview;否则就滑动自己。
scrollsToTop
当用户轻点状态栏时,系统会要求离状态栏近的scrollview把自己的内容滑到最上面。如果这个属性是false,就会忽略这个请求。
On iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to true.
设置特定区域可见
scrollRectToVisible(_ rect: CGRect, animated: Bool)
设置分页
scrollView.pagingEnabled = true
当停止滑动时,会停到scrollview的大小的整数倍
设置方向锁定。
一般来说,scrollview可以在横向、纵向滑动。设定锁定以后,就只能在一个方向锁定了。在哪个方向锁定要看在哪个方向移动的距离大。
scrollView.directionalLockEnabled = true
Scroll Indicator
就是滑动时出现的那条线
scrollView.indicatorStyle = .Black
scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 5, 10, 30)
button.addTarget(self, action: #selector(ViewController.flashIndicator(_:)), forControlEvents: .TouchUpInside)
func flashIndicator(sender:UIButton) -> Void {
scrollView.flashScrollIndicators()
}
和键盘的交互
var keyboardDismissMode: UIScrollViewKeyboardDismissMode { get set
interactive
The keyboard follows the dragging touch offscreen, and can be pulled upward again to cancel the dismiss。
UIScrollViewDelegate调用顺序
isDragging, isTracking
scrollViewWillBeginDecelerating
之后,istracking变为falsescrollViewDidEndDecelerating
之前,isdragging为truescrollViewWillEndDragging
之前是true标签:dism efault getc ima bool role lld 触摸 led
原文地址:http://www.cnblogs.com/huahuahu/p/UIScrollView-bi-ji.html