I need somehow to keep scrollview always scrolled to bottom while its height decreases.
It's hard to solve while bounds change animated. Is there some "gravity"-property for purpose like that?
You can achieve this behaviour by using a non-animated version of setContentOffset
within the same animation block you use for resizing the UIScrollView
— in this case both changes will be animated simultaneously. Something like:
UIView.animateWithDuration(0.5, animations: { () -> Void in
let delta: CGFloat = 100
/// Change UIScrollView's height with some delta value, for instance:
self.scrollView.frame.size.height -= delta
/// Update content offset with the same delta value:
self.scrollView.contentOffset.y += delta
})
每次缩小UIScrollView
的框架时,尝试使用setContentOffset:animated:
滚动到底部。
You are decreasing the height of scrollview with animation. You can use setContentOffset:animated:
in the animation completion block. It will keep the scrollview always scrolled to bottom.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.