我注意到在使用 (Swift 4.0) 的 IOS X 代码中,我至少可以通过以下两种方式请求 View 的高度 V:
V.bounds.size.height
和...
V.bounds.height
这两者之间有什么实际区别吗?
我做了选项单击的事情(它给出了不同的定义,但没有解释任何实际差异或原因)......和 stackoverflow ......但是在 stackoverflow 上,所有结果都在讨论bounds 和 frame 之间的区别...这不是我要问的。
最佳答案
V.bounds.height
只是一个 GET 属性。您不能为此属性设置值。
示例:
self.view.bounds.height = 5
此错误消息结果...
Cannot assign to property: 'height' is a get-only property
如果你想给这个属性赋值,那么你可以写...
self.view.bounds.size.height = 5
所以你可以给这个对象设置值。看看here.
关于ios - view.bounds.size.height -vs- view.bounds.height——有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53849085/