gpt4 book ai didi

ios - 动画期间无法最小化 subview 和主视图

转载 作者:行者123 更新时间:2023-11-30 12:11:05 24 4
gpt4 key购买 nike

我有两个 View ,videoView(主视图)和subVideoView(主视图的 subview )。

我试图同时使用动画最小化两个 View ,如下面的代码所示。我能够最小化 videoView(即 mainView)而不是 subVideoView。

但是,当我隐藏用于最小化 videoView(即 mainView)的代码时,我可以最小化 subVideoView。

我相信这与我制作动画的方式有关。

有人可以建议我如何同时使用动画最小化两个 View (按比例)并最终得到以下结果。

enter image description here

现有代码的结果 enter image description here

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
}

最佳答案

根据您的要求在ma​​inView中添加subViews并设置

mainView.clipsToBounds = true

并且在 minimiseOrMaximiseViews 方法中,您只需要管理 ma​​inViewY 轴的显示和隐藏。

关于ios - 动画期间无法最小化 subview 和主视图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46053072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com