[英]IOS - How do you get current scrollview position in swift?
I have a scrollview in swift which user can scroll up and down freely.我在 swift 中有一个滚动视图,用户可以自由上下滚动。 When a user scrolls, stops at somewhere and hit a button in the scroll view, how do I know the current position of the scrollview?
当用户滚动,停在某处并点击滚动视图中的按钮时,我如何知道滚动视图的当前 position?
To be detailed, I need a要详细,我需要一个
currentPosition: CGPoint
such that the scrollview will be exactly the same as it appears when I do这样滚动视图将与我执行时出现的完全相同
thisScrollView.setContentOffset(currentPosition, animated: false)
This is the current position of scrollView.这是scrollView当前的position。
scrollView.contentOffset
You can use the scrollView.contentOffset.y for your visible screen in all scrollable area(ContentSize).您可以在所有可滚动区域 (ContentSize) 中为您的可见屏幕使用 scrollView.contentOffset.y。 And you can use the all scrollable are --> scrollView.contentSize.height
你可以使用所有可滚动的 --> scrollView.contentSize.height
scrollView.contentSize.height = scrollView.contentOffset.y + scrollView.frame.size.height scrollView.contentSize.height = scrollView.contentOffset.y + scrollView.frame.size.height
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.