自动版式与旋转的UI元素 [英] AutoLayout with rotated UI Elements

查看:122
本文介绍了自动版式与旋转的UI元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在自学自动布局使用code(即,避免接口生成器)。

I've been teaching myself Auto Layout using code (i.e. avoiding Interface Builder).

我有我想设置了自动布局

它有3个 UILabels 是水平和一个是垂直的。

It has 3 UILabels that are horizontal and one that is vertical.

Sort of like this.
---------------------------------------------
| ---  -----------------------------------  |
| | |  |                                 |  |
| | |  -----------------------------------  |
| | |  -----------------------------------  |
| | |  |                                 |  |
| | |  -----------------------------------  |
| | |  -----------------------------------  |
| | |  |                                 |  |
| ---  -----------------------------------  |
---------------------------------------------

左边的标签被旋转90度到左侧。

The label on the left is rotated 90 degrees to the left.

我只是不知道如何旋转标签和非旋转标签之间的应用自动布局?

I'm just not sure how to apply auto layout between the rotated label and the non-rotated labels?

可以这样做?

请问高度成为宽度,莫非成为离开,等...

Does the height become the width, does the top become the left, etc...

推荐答案

有可能是一个正确的答案,但一个简单的解决方法是将旋转的标签添加为不可旋转的意见子视图,并做你​​的布局这些看法。

There is probably a "right" answer, but an easy workaround would be to add the rotated labels as subviews of non-rotated views, and do your layout with those views.

更新:我只记得,当一个视图有一个转换应用,框变成可能的最小边界框*。除非我记错了,这意味着框架会正是你想要的它是,并且假设计算是基于框架上的布局,它应该工作正常。

Update: I just remembered that when a view has a transform applied, the frame becomes the smallest possible bounding frame*. Unless I'm mistaken, that means the frame would be exactly what you want it to be, and assuming the layout calculations are based on the frame, it should work as expected.

*当我最后一次与改造工作的意见,一个旋转视图的框架是不确定的,但实验表明,它旋转视图的边界矩形。不知道是否现在定义或前pressly允许/禁止的。

* when I last worked with transformed views, the frame of a rotated view was undefined, but experimentation showed that it was the bounding rect of the rotated view. Not sure if it is now defined or expressly allowed/forbidden.

更新2:我查了<一个href=\"https://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/uiview/uiview.html#//apple_ref/occ/instp/UIView/frame\"相对=nofollow>文档,他们仍然有反对这样做了一份措辞强烈的警告:

Update 2: I checked the docs, and they still have a strongly worded warning against doing this:

警告:如果变换属性不是恒等变换,这个属性的值是不确定的,因此应被忽略

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

这篇关于自动版式与旋转的UI元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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