在 CGAffineTransform (Rotate) 之后 view.frame.size 属性会发生什么?

What happens to the view.frame.size attribute after a CGAffineTransform (Rotate)?(在 CGAffineTransform (Rotate) 之后 view.frame.size 属性会发生什么?)

本文介绍了在 CGAffineTransform (Rotate) 之后 view.frame.size 属性会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIImageView,可以通过捏合来调整大小(例如:view.frame.size.width+10).Image View 的图像也可以旋转(CGAffineTransformMakeRotate).好的,问题来了:当我在应用 Rotate Transform 之后调整 UIImageView 的大小时,视图会异常调整大小(相反(当它应该增长时缩小,反之亦然)或以巨大的调整大小单位增量).无论是否应用 CGAffineTransform,如何以一致的方式调整 UIImageView 的大小?

I have a UIImageView that can be resized by pinching in and out (Example: view.frame.size.width+10). The image of the Image View can also be rotated (CGAffineTransformMakeRotate). Okay, here is the problem: When I resize the UIImageView AFTER having had applied a Rotate Transform the view resizes abnormally (inversly (shrink when it should grow, vice-versa) or at enormous resize unit increments). How can I resize my UIImageView in a consistent manner whether or not a CGAffineTransform is applied?

推荐答案

UIView 表示,对于 frame 属性:

There's a warning in the documentation for UIView that says, for the frame property:

警告:如果 `transform` 属性不是恒等变换,则该属性的值是未定义的,因此应该被忽略.
Warning: If the `transform` property is not the identity transform, the value of this property is undefined and therefore should be ignored.

改用 boundscenter 属性;它们在应用转换后仍然可行.

Use the bounds and center properties instead; they remain viable after a transform is applied.

这篇关于在 CGAffineTransform (Rotate) 之后 view.frame.size 属性会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 CGAffineTransform (Rotate) 之后 view.frame.size 属性会发生什么?

基础教程推荐