轻松访问用 Swift 编写的 UIView 和 CALayer 的布局(灵感来自 FrameAccessor)。
只需将 Brief.swift 添加到您的项目中。
// Before
view.frame.origin.x = 20.0
view.frame.size.width = 200.0
view.frame.origin.y = 100.0 - view.frame.size.height // Make view's bottom to 100.0
// After
view.x = 20.0
view.width = 200.0
view.bottom = 100.0
UIView 属性
| 属性 | 类型 | 可选项 |
|---|---|---|
x, y | CGFloat | get/set |
width, height | CGFloat | get/set |
top, left, bottom, right | CGFloat | get/set |
boundsWidth, boundsHeight | CGFloat | get/set |
boundsTop, boundsLeft, boundsBottom, boundsRight | CGFloat | get/set |
CALayer 属性
| 属性 | 类型 | 可选项 |
|---|---|---|
x, y | CGFloat | get/set |
width, height | CGFloat | get/set |
top, left, bottom, right | CGFloat | get/set |
boundsWidth, boundsHeight | CGFloat | get/set |
boundsTop, boundsLeft, boundsBottom, boundsRight | CGFloat | get/set |
以下属性在 Swift 中已无用且已移除。
UIView
frameOrigin, frameSizecenterX, centerYmiddlePoint, middleX, middleYUIScrollView
CALayer
frameOrigin, frameSizeanchorX, anchorYpositionX, positionYApache 2.0 许可协议