• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UIInterfaceOrientation、CGAffineTransform、框架、边界和中心

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:45:43 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

有人能指点我上面的一本很好的入门书吗?当你和其他人搞混时会发生什么?似乎无论我做什么,一旦我开始弄乱状态栏方向或 View 变换(即使我所做的只是 90 度旋转),我可以指望我的 View 最终会横向,向上上下颠倒,在一个令人沮丧的下午尝试和错误试图让它们理顺。我敢肯定,一旦您知道了逻辑以及应用所有内容的顺序,这一切都是有道理的,但是到目前为止,凭经验,我还无法弄清楚。



Best Answer-推荐答案


我不知道关于该主题的好的单文档入门,但以下是我从经验和阅读文档中学到的东西。

中心、边界和框架

如果您设置框架,则中心和边界将被更新。如果您设置中心或边界,则框架将被更新。 Frame 是一种使用 super View 的坐标系来操作中心和边界的便捷方法。

来自 UIView Class Reference :

The geometry of a view is defined by its frame, bounds, and center properties. The frame defines the origin and dimensions of the view in the coordinate system of its superview and is commonly used during layout to adjust the size or position of the view. The center property can be used to adjust the position of the view without changing its size. The bounds defines the internal dimensions of the view as it sees them and is used almost exclusively in custom drawing code. The size portion of the frame and bounds rectangles are coupled together so that changing the size of either rectangle updates the size of both.

The Relationship of the Frame, Bounds, and Center Properties了解更多详情。

变换

如果您将变换属性设置为身份变换之外的其他内容,则框架未定义。如果您将变换设置为其他内容,您应该只使用中心(将 View 定位在其 super View 中)和边界(调整 View 的大小)来操作 View 几何图形。以下是来自 UIView Class Reference 的相关信息:

The origin of the transform is the value of the center property, or the layer’s anchorPoint property if it was changed. (Use the layer property to get the underlying Core Animation layer object.) The default value is CGAffineTransformIdentity.

...

Warning If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.

Coordinate System Transforms了解更多详情。

UIInterfaceOrientation

UIInterfaceOrientation 不会直接影响变换、边界、中心或框架属性。但是,当设备方向发生变化时, View Controller 会自动调整其 subview 的大小(这会反过来调整其 subview 的大小等等)。

Responding to Device Orientation ChangesView Controller View Resizing了解更多详情。

关于ios - UIInterfaceOrientation、CGAffineTransform、框架、边界和中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4675870/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap