我完全知道你不能UIViewController
从UINavigationController
. 但是我的实施要求如此。我必须滑动手势。在从右向左滑动时,我必须重新加载视图的内容(即 a UIScrollView
)以及动画。反之亦然,从左到右滑动。我尝试过以下操作,但没有给出预期的动画:
func leftSwipe()
{
self.scroll_course_detail.frame = CGRect(x: 2*self.scroll_course_detail!.frame.size.width, y: self.scroll_course_detail.frame.origin.y, width: self.scroll_course_detail.frame.size.width, height: self.scroll_course_detail.frame.size.height)
UIView.animate(withDuration: 0.25, animations: {() -> Void in
self.scroll_course_detail.frame = CGRect(x: 0, y: self.scroll_course_detail.frame.origin.y, width: self.scroll_course_detail.frame.size.width, height: self.scroll_course_detail.frame.size.height)
})
}
func rightSwipe()
{
self.scroll_course_detail.frame = CGRect(x: -self.scroll_course_detail!.frame.size.width, y: self.scroll_course_detail.frame.origin.y, width: self.scroll_course_detail.frame.size.width, height: self.scroll_course_detail.frame.size.height)
UIView.animate(withDuration: 0.25, animations: {() -> Void in
self.scroll_course_detail.frame = CGRect(x: 0, y: self.scroll_course_detail.frame.origin.y, width: self.scroll_course_detail.frame.size.width, height: self.scroll_course_detail.frame.size.height)
})
}
在动画块之前,我正在更改UIScrollView
使动画持续时间的背景清晰的帧。我在想UIScrollView
内容与动画一起被覆盖那么在滑动时重新加载内容和动画的最佳方法应该是什么?