我有两个视图,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