【发布时间】:2017-09-05 10:45:51
【问题描述】:
我有两个view,videoView(mainView)和subVideoView(mainView的subView)。
我正在尝试同时使用动画最小化两个视图,如下面的代码所示。我能够最小化 videoView(即 mainView)而不是 subVideoView。
但是,当我隐藏用于最小化 videoView(即 mainView)的代码时,我能够最小化 subVideoView。
我认为这与我制作动画的方式有关。
有人可以请教我如何用动画同时最小化两个视图(按比例)并最终得到以下结果。
func minimiseOrMaximiseViews(animationType: String){
UIView.animate(withDuration: 0.5, delay: 0, options: [],
animations: { [unowned self] in
switch animationType {
case "minimiseView" :
// Minimising subVideoView
self.subVideoView.frame = CGRect(x: self.mainScreenWidth - self.minSubVideoViewWidth - self.padding,
y: self.mainScreenHeight - self.minSubVideoViewHeight - self.padding,
width: self.minSubVideoViewWidth,
height: self.minSubVideoViewHeight)
// Minimising self i.e videoView
self.frame = CGRect(x: self.mainScreenWidth - self.videoViewWidth - self.padding,
y: self.mainScreenHeight - self.videoViewHeight - self.padding,
width: self.videoViewWidth,
height: self.videoViewHeight)
self.layoutIfNeeded()
case "maximiseView":
// Maximising videoView
self.frame = CGRect(x: 0, y: 0, width: self.mainScreenSize.width, height: self.mainScreenSize.height)
// Maximising subVideoView
self.subVideoView.frame = CGRect(x: self.mainScreenWidth - self.maxSubVideoViewWidth - self.padding,
y: self.mainScreenHeight - self.maxSubVideoViewHeight - self.padding - self.buttonStackViewBottomPadding - buttonStackViewHeight,
width: self.maxSubVideoViewWidth,
height: self.maxSubVideoViewHeight)
default:
break
}
【问题讨论】:
标签: ios swift uiview uiviewanimation uianimation