1

我有两个相互重叠的 ContainerView,例如 ContainerA 在 ContainerB 的前面。

当 Button 点击​​ ContainerA 的宽度和高度应更改为较小的尺寸时,将显示 ContainerB。

如何使用 swift 而不是故事板更改容器视图的高度和宽度?它有类似变换的东西吗?

4

1 回答 1

0

改变它的框架:

let currentContainerViewFrame = containerView?.frame
currentContainerViewFrame?.width -= 200
currentContainerViewFrame?.height -= 200
containerView?.frame = currentContainerViewFrame

或使用其变换属性:

containerView?.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.7, 0.7)
于 2016-04-03T12:48:56.677 回答