缩放UIView而不缩放子视图 [英] Scale UIView without scaling subviews

查看:995
本文介绍了缩放UIView而不缩放子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试缩放UIView而不缩放其子视图,或者在我的情况下,我只想在一个轴上缩放子视图。我需要这些层次结构,因为我正在设置一些手势识别器来检测平移和旋转,我希望这些与父视图同时发生。

I'm trying to scale an UIView without scaling its subviews, or in my case I just want the subviews to be scaled in one axis. I need these hierarchy because I'm setting some Gesture Recognizers to detect panning and rotation and I want these to happen simultaneously with the parent view.

但是,我不希望缩放同时发生。对于某些子视图,我希望它只在垂直或水平方向发生,或者根本不进行缩放。

However, I don't want the scaling to happen simultaneously. For some subviews I want it to happen only vertically or horizontally or no scaling at all.

使用CGAffineTransform时,有没有办法控制UIView子视图中的自动缩放在UIView上?

Is there a way to control the auto-scaling in an UIView's subviews when using CGAffineTransform on the UIView?

推荐答案

如果确保正确设置了autoresizingMask的子视图,则可以更改容器的框架UIView (它是可动画的)并且子视图不会改变大小(如果你的大小调整掩码是正确的)。关闭containerView.autoresizesSubviews并更改框架也应该有效。

If you ensure the autoresizingMask's of subviews is correctly set up, you can change the frame of the container UIView (it is animatable) and the subviews will not change size (if your resizing mask is correct). Turning off containerView.autoresizesSubviews and changing the frame should also work.

这篇关于缩放UIView而不缩放子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆