【问题标题】:How to get UIView frame position after transform?变换后如何获取 UIView 框架位置?
【发布时间】:2010-12-16 07:19:20
【问题描述】:

我想在应用了变换旋转后获取 UIView 的当前位置。我该怎么做?

在 UIView 文档中,我发现了有关转换属性的信息:

"如果该属性不是恒等变换,则 frame 属性的值是未定义的,因此应该被忽略。"

我尝试使用 center 和 bounds 但结果被翻译(即使没有对旋转视图应用任何变换)

newView.center = rotatedView.center;
newView.bounds = rotatedView.bounds;
newView.transform = rotatedView.transform;

有人可以帮忙吗?

提前致谢,文森特。

【问题讨论】:

    标签: uiview transform frame


    【解决方案1】:

    如果你知道变换前的帧,你可以使用CGRectApplyAffineTransform函数计算变换后的值。

    【讨论】:

    • 请您详细介绍一下如何使用 CGRectApplyAffineTransform?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 1970-01-01
    相关资源
    最近更新 更多