我有兩個視圖,videoView(它是mainView)和subVideoView(它是mainView的子視圖)。無法在動畫過程中將mainview旁邊的子視圖最小化
我想盡量減少兩個視圖同時使用動畫,如下面的代碼所示。我能夠最小化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
}
我想最小化視圖,即減少視圖大小。我不想clipToBounds,因爲它只是剪輯,並不會減少視圖大小。 – user44776
@moritz,添加了詳細的圖像,以更好地解釋問題 – user44776