下面这个实现一个ScrollView里的一张长图片慢慢滚到下方,然后再慢慢滚回上方。各种时间点均可调整。
DispatchQueue.main.asyncAfter(deadline:DispatchTime.now() +1.0, execute: {
UIView.animate(withDuration:2.0, animations: {
self.scrollView.contentOffset=CGPoint(x:0,y:self.scrollView.contentSize.height-self.scrollView.frame.height)
})
})
DispatchQueue.main.asyncAfter(deadline:DispatchTime.now() +3.0, execute: {
UIView.animate(withDuration:2.0, animations: {
self.scrollView.contentOffset=CGPoint.zero
})
})
网友评论