Skip to content

Commit 5c0073d

Browse files
authored
Merge pull request #216 from gyuchan/master
Add border function in Flex class
2 parents d719230 + aa8e3f6 commit 5c0073d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ FlexLayout also adds methods to set common UIView properties.
997997
Set the flex item's UIView background color.
998998
* **`cornerRadius(_ value: CGFloat)`**
999999
Set the flex item's UIView rounded corner radius.
1000+
* **`border(_ width: CGFloat, _ color: UIColor)`**
1001+
Set the flex item's UIView border.
10001002

10011003
###### Usage examples:
10021004
```swift
@@ -1006,6 +1008,8 @@ Set the flex item's UIView rounded corner radius.
10061008
}
10071009
// Set rounded corner
10081010
flex.addItem().cornerRadius(12)
1011+
// Set border
1012+
flex.addItem().border(1, .black)
10091013
```
10101014

10111015
<br>

Sources/Swift/FlexLayout.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ public final class Flex {
179179
Note that row and row-reverse are affected by the layout direction (see `layoutDirection` property) of the flex container.
180180
If its text direction is LTR (left to right), row represents the horizontal axis oriented from left to right, and row-reverse
181181
from right to left; if the direction is rtl, it's the opposite.
182-
183-
- Parameter value: Default value is .column
184182
*/
185183
public var direction: Direction? {
186184
get {
@@ -1250,6 +1248,25 @@ public final class Flex {
12501248
preconditionFailure("Trying to modify deallocated host view")
12511249
}
12521250
}
1251+
1252+
/**
1253+
Set the view to border width and color
1254+
1255+
- Parameters:
1256+
- width: border width
1257+
- color: border color
1258+
- Returns: flex interface
1259+
*/
1260+
@discardableResult
1261+
public func border(_ width: CGFloat, _ color: UIColor) -> Flex {
1262+
if let host = self.view {
1263+
host.layer.borderWidth = width
1264+
host.layer.borderColor = color.cgColor
1265+
return self
1266+
} else {
1267+
preconditionFailure("Trying to modify deallocated host view")
1268+
}
1269+
}
12531270

12541271
//
12551272
// MARK: Display

0 commit comments

Comments
 (0)