Skip to content

Commit f630895

Browse files
authored
Merge pull request #209 from minhaaan/master
Add cornerRadius
2 parents 48d4f16 + ec9c6b9 commit f630895

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,13 +991,17 @@ FlexLayout also adds methods to set common UIView properties.
991991

992992
* **`backgroundColor(_ color: UIColor)`**
993993
Set the flex item's UIView background color.
994+
* **`cornerRadius(_ value: CGFloat)`**
995+
Set the flex item's UIView rounded corner radius.
994996

995997
###### Usage examples:
996998
```swift
997999
// Create a gray column container and add a black horizontal line separator
9981000
flex.addItem().backgroundColor(.gray).define { (flex) in
9991001
flex.addItem().height(1).backgroundColor(.black)
1000-
}
1002+
}
1003+
// Set rounded corner
1004+
flex.addItem().cornerRadius(12)
10011005
```
10021006

10031007
<br>

Sources/Swift/FlexLayout.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,23 @@ public final class Flex {
12071207
}
12081208
}
12091209

1210+
1211+
/**
1212+
Set the view to rounded corner
1213+
1214+
- Parameter value: value specifies the view's layer cornerRadius.
1215+
- Returns: flex interface
1216+
*/
1217+
@discardableResult
1218+
public func cornerRadius(_ value: CGFloat) -> Flex {
1219+
if let host = self.view {
1220+
host.layer.cornerRadius = value
1221+
return self
1222+
} else {
1223+
preconditionFailure("Trying to modify deallocated host view")
1224+
}
1225+
}
1226+
12101227
//
12111228
// MARK: Display
12121229
//

0 commit comments

Comments
 (0)