You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-9Lines changed: 52 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,13 +38,14 @@ Extremely Fast views layouting without auto layout. No magic, pure code, full co
38
38
* Swift 3.2+ / Swift 4.1 / Objective-C
39
39
40
40
### Recent changes/features
41
+
*:star: Add [`pin.readableMargins` and `pin.layoutMargins`](#layout_margins) properties.
41
42
*:star: Add `sizeToFit()` method. See [Adjusting size](#adjusting_size).
42
43
*:star: PinLayout can now layout CALayer. See [CALayer Support](#calayer_support) for more information.
43
44
*:star: PinLayout is in the Top 10 of Swift Layout frameworks on [Awesome Swift](https://swift.libhunt.com/categories/714-layout)
44
45
*:star: PinLayout has moved to the **[layoutBox](https://github.com/layoutBox)** organization. See other **[layoutBox](https://github.com/layoutBox)** projects.
45
46
*:star: Add `wrapContent()` methods that adjust view's width and height to wrap all its subviews. See [wrapContent](#wrapContent) for more information.
46
47
*:star: PinLayout now support macOS. See [macOS Support](#macos_support) for more information.
47
-
*:star: PinLayout expose the `safeAreaInsets` through [`UIView.pin.safeArea`](#safeAreaInsets), this property support not only iOS 11, but is also backward compatible for earlier iOS releases (7/8/9/10). See [safeAreaInsets support](#safeAreaInsets) for more information.
48
+
*:star: PinLayout expose the `safeAreaInsets` through [`pin.safeArea`](#safeAreaInsets), this property support not only iOS 11, but is also backward compatible for earlier iOS releases (7/8/9/10). See [safeAreaInsets support](#safeAreaInsets) for more information.
48
49
49
50
50
51
@@ -185,13 +186,12 @@ As you can see in the following chart, PinLayout are faster or equal to manual l
185
186
### UIKit safeAreaInsets support
186
187
PinLayout can easily handle iOS 11 `UIView.safeAreaInsets`, but it goes even further by supporting safeAreaInsets for previous iOS releases (including iOS 7/8/9/10) by adding a property `UIView.pin.safeArea`. [See here for more details](#safeAreaInsets)
187
188
188
-
<aname="rtl_support"></a>
189
-
190
189
### macOS support
191
190
PinLayout support macOS 10.9+.
192
191
193
192
:pushpin: In this documentation, any methods with parameters of type UIView or UIEdgeInsets are also supported on macOS, using NSView and NSEdgeInsets. See [macOS Support](#macos_support) for more information.
194
193
194
+
<aname="rtl_support"></a>
195
195
### Right to left languages (RTL) support
196
196
PinLayout supports left-to-right (LTR) and right-to-left (RTL) languages.
197
197
#### [See here for more details](docs/rtl_support.md).
@@ -1120,7 +1120,22 @@ This example layout an UIImageView at the top and center it horizontally, it als
1120
1120
1121
1121
1122
1122
<aname="safeAreaInsets"></a>
1123
-
## UIKit safeAreaInsets support
1123
+
## UIKit safeArea, readable and layout margins
1124
+
1125
+
UIKit expose 3 kind of areas/guides that can be used to layout views.
See the **SafeArea & readableMargins** example in the [Examples App](#examples_app).
1137
+
1138
+
### 1. pin.safeArea
1124
1139
1125
1140
PinLayout can handle easily iOS 11 `UIView.safeAreaInsets`, but it goes further by supporting safeAreaInsets for previous iOS releases (including iOS 7/8/9/10) by adding a property `UIView.pin.safeArea`. PinLayout also extends the support of `UIView.safeAreaInsetsDidChange()` callback on iOS 7/8/9/10.
1126
1141
@@ -1146,8 +1161,6 @@ The safe area of a view represent the area not covered by navigation bars, tab b
1146
1161
button.pin.top(view.pin.safeArea)
1147
1162
```
1148
1163
1149
-
1150
-
1151
1164
##### UIView.safeAreaInsetsDidChange():
1152
1165
1153
1166
* iOS 11 has also introduced the method [`UIView.safeAreaInsetsDidChange()`](https://developer.apple.com/documentation/uikit/uiview/2891104-safeareainsetsdidchange) which is called when the safe area of the view changes. This method is called only when your app runs on a iOS 11 device. **PinLayout's extend that and support this method also on older iOS releases including iOS 9/10**.
@@ -1194,8 +1207,6 @@ The safe area of a view represent the area not covered by navigation bars, tab b
1194
1207
}
1195
1208
```
1196
1209
* **disable**: In this mode PinLayout won't call `UIView.safeAreaInsetsDidChange` on iOS 8/9/10. Note that this is the default mode on iOS 8.
1197
-
1198
-
<br>
1199
1210
1200
1211
###### Example using `UIView.pin.safeArea`
1201
1212
This example layout 4 subviews inside the safeArea. The UINavigationBar and UITabBar are translucent, so even if the container UIView goes under both, we can use its `UIView.pin.safeArea` to keeps its subviews within the safeArea.
@@ -1214,6 +1225,38 @@ This example runs perfectly on a iPhone X (iOS 11), but it also runs on any devi
1214
1225
:pushpin: This example is available in the [Examples App](#examples_app). See example complete [source code](https://github.com/layoutBox/PinLayout/blob/master/Example/PinLayoutSample/UI/Examples/SafeArea/SafeAreaView.swift)
1215
1226
1216
1227
1228
+
<br/>
1229
+
1230
+
<aname="readableMargins"></a>
1231
+
### 2. pin.readableMargins
1232
+
1233
+
##### Property:
1234
+
***`pin.readableMargins: UIEdgeInset`**:
1235
+
PinLayout's `UIView.pin.readableMargins` property expose UIKit [`UIView.readableContentGuide`](https://developer.apple.com/documentation/uikit/uiview/1622644-readablecontentguide) as an UIEdgeInsets. This is really useful since UIKit only expose the readableContent area to Auto Layout using UILayoutGuide.
1236
+
1237
+
###### Usage examples:
1238
+
```swift
1239
+
label.pin.horizontally(pin.readableMargins) // the label fill horizontally the readable area.
1240
+
view.pin.all(container.pin.readableMargins) // the view fill its parent's readable area.
1241
+
view.pin.left(pin.readableMargins)
1242
+
```
1243
+
1244
+
:pushpin: The [Examples App](#examples_app) contains some examples using `pin.readableMargins`.
1245
+
1246
+
<br/>
1247
+
1248
+
### 3. pin.layoutmargins
1249
+
1250
+
##### Property:
1251
+
***`pin.layoutmargins: UIEdgeInset`**
1252
+
PinLayout's `UIView.pin.layoutMargins` property expose directly the value of UIKit [`UIView.layoutMargins`](https://developer.apple.com/documentation/uikit/uiview/1622566-layoutmargins). The property exists only to be consistent with the other areas: `pin.safeArea`, `pin.readableMargins` and `pin.layoutmargins`. So its usage is not necessary.
1253
+
1254
+
###### Usage example:
1255
+
```swift
1256
+
view.pin.left(container.pin.layoutmargins)
1257
+
view.pin.left(container.layoutmargins) // Similar to the previous line
1258
+
```
1259
+
1217
1260
<br/>
1218
1261
1219
1262
<aname="wrapContent"></a>
@@ -1593,7 +1636,7 @@ Included examples:
1593
1636
* Example using a UITableView with variable height cells.
1594
1637
* Example using a UICollectionView with variable height cells.
1595
1638
* Example showing how to animate with PinLayout.
1596
-
* Example using [`UIView.pin.safeArea`](#safeAreaInsets)
1639
+
* Example using [`pin.safeArea`, `pin.readableMargins` and `pin.layoutMargins`](#safeAreaInsets)
1597
1640
* Example using [`wrapContent()`](#wrapContent)
1598
1641
* Example showing right-to-left (RTL) language support.
## UITableView Example with cells using `pin.readableMargins`
48
+
Similar to the UITableView Example, but in this one cells use `pin.readableMargins` to layout their content inside the zone defined by `UIView.readableContentGuide`.
0 commit comments