Skip to content

Commit 2efd88e

Browse files
author
Luc Dion
committed
Add new margin method:
* margin(_ insets: UIEdgeInsets) Set all margins using an UIEdgeInsets. This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`.
1 parent 2d2012e commit 2efd88e

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
language: objective-c
2-
osx_image: xcode9
2+
osx_image: xcode8.3
33

44
env:
55
matrix:
6-
- SCHEME=PinLayout SDK=iphonesimulator11.0
7-
- SCHEME=PinLayoutSample SDK=iphonesimulator11.0
8-
- SCHEME=PinLayoutTVOS SDK=appletvsimulator11.0
6+
- SCHEME=PinLayout SDK=iphonesimulator10.3
7+
- SCHEME=PinLayoutSample SDK=iphonesimulator10.3
8+
- SCHEME=PinLayoutTVOS SDK=appletvsimulator10.2
99

1010
before_install:
1111
# - brew outdated xctool || brew upgrade xctool;
12-
# - bundle install
1312
- gem install xcpretty-travis-formatter;
1413
- gem install cocoapods --no-document --quiet;
1514
# - pod repo update --silent;

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,7 @@ Set the top and bottom margins to the specified value.
919919
* **`margin(_ value: CGFloat)`**
920920
Apply the value to all margins (top, left, bottom, right)
921921
* **`margin(_ insets: UIEdgeInsets)`**
922-
Set margins using UIEdgeInsets. This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`.
923-
* **`margin(_ directionalInsets: NSDirectionalEdgeInsets)`**
924-
Available only on iOS 11 and higher.
922+
Set all margins using an UIEdgeInsets. This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`.
925923
* **`margin(_ vertical: CGFloat, _ horizontal: CGFloat)`**
926924
Set the individually vertical margins (top, bottom) and horizontal margins (left, right, start, end)
927925
* **`margin(_ top: CGFloat, _ horizontal: CGFloat, _ bottom: CGFloat)`**

Sources/PinLayout.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public protocol PinLayout {
337337
@discardableResult func marginVertical(_ value: CGFloat) -> PinLayout
338338

339339
/**
340-
Set margins using UIEdgeInsets.
340+
Set all margins using UIEdgeInsets.
341341
This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`.
342342
*/
343343
@discardableResult func margin(_ insets: UIEdgeInsets) -> PinLayout
@@ -348,8 +348,8 @@ public protocol PinLayout {
348348

349349
Available only on iOS 11 and higher.
350350
*/
351-
@available(iOS 11.0, *)
352-
@discardableResult func margin(_ directionalInsets: NSDirectionalEdgeInsets) -> PinLayout
351+
//@available(iOS 11.0, *)
352+
//@discardableResult func margin(_ directionalInsets: NSDirectionalEdgeInsets) -> PinLayout
353353

354354
/**
355355
Set all margins to the specified value.

Sources/PinLayoutImpl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,15 +779,15 @@ class PinLayoutImpl: PinLayout {
779779
return self
780780
}
781781

782-
@available(iOS 11.0, *)
782+
/*@available(iOS 11.0, *)
783783
@discardableResult
784784
func margin(_ directionalInsets: NSDirectionalEdgeInsets) -> PinLayout {
785785
marginTop = directionalInsets.top
786786
marginBottom = directionalInsets.bottom
787787
marginStart(directionalInsets.leading)
788788
marginEnd(directionalInsets.trailing)
789789
return self
790-
}
790+
}*/
791791

792792
@discardableResult
793793
func margin(_ value: CGFloat) -> PinLayout {

Tests/MarginsSpec.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ class MarginsSpec: QuickSpec {
557557
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)))
558558
}
559559

560-
if #available(iOS 11.0, *) {
560+
/*if #available(iOS 11.0, *) {
561561
it("should adjust the aView") {
562562
Pin.layoutDirection(.ltr)
563563
aView.pin.top().bottom().start().end().margin(NSDirectionalEdgeInsets(top: 10, leading: 20, bottom: 30, trailing: 40))
@@ -575,7 +575,7 @@ class MarginsSpec: QuickSpec {
575575
aView.pin.top().bottom().start().end().margin(NSDirectionalEdgeInsets(top: 10, leading: 20, bottom: 30, trailing: 40))
576576
expect(aView.frame).to(equal(CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)))
577577
}
578-
}
578+
}*/
579579
}
580580
}
581581
}

0 commit comments

Comments
 (0)