Skip to content

Commit 3497d6b

Browse files
SahilSainiYMLmpospese
authored andcommitted
[UPDATE] updated according to review comment
1 parent ae37021 commit 3497d6b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@ Documentation is automatically generated from source code comments and rendered
1818
Usage
1919
----------
2020

21-
## 1. UIView extensions for declarative Auto Layout
21+
### 1. UIView extensions for declarative Auto Layout
2222

2323
To aid in auto layout, Y—CoreUI has several `UIView` extensions that simplify creating layout constraints. These do not use any 3rd party library such as SnapKit, but are simply wrappers around Apple’s own `NSLayoutConstraint` api’s. If you are more comfortable using Apple’s layout constraint api’s natively, then by all means go ahead and use them. But these convenience methods allow for less verbose code that expresses its intent more directly.
2424

2525
All the extensions are to `UIView` and begin with the word `constrain`.
2626

2727
The simplest flavor just creates constraints using attributes just like the original iOS 6 `NSLayoutContraint` api.
2828

29-
3029
```swift
31-
//constrain a button's width to 100
30+
// constrain a button's width to 100
3231
let button = UIButton()
3332
addSubview(button)
3433
button.constrain(.width, constant: 100)
3534

36-
//constrain view to superview**
35+
// constrain view to superview
3736

3837
let container = UIView()
3938
addSubview(container)
@@ -46,7 +45,7 @@ container.constrain(.bottom, to: .bottom, of: superview)
4645
Another flavor creates constraints using anchors just like the anchor api’s first introduced in iOS 9.
4746

4847
```swift
49-
//constrain a button's width to 100
48+
// constrain a button's width to 100
5049
let button = UIButton()
5150
addSubview(button)
5251
button.constrain(.widthAnchor, constant: 100)
@@ -113,7 +112,7 @@ addSubview(container)
113112
container.constrainEdgesToMargins()
114113
```
115114

116-
## 2. UIColor extensions for WCAG 2.0 contrast ratio calculations
115+
### 2. UIColor extensions for WCAG 2.0 contrast ratio calculations
117116

118117
Y—CoreUI contains a number of extensions to make working with colors easier. The most useful of them may be WCAG 2.0 contrast calculations. Given any two colors (representing foreground and background colors), you can calculate the contrast ration between them and evaluate whether that passes particular WCAG 2.0 standards (AA or AAA). You can even write unit tests to quickly check all color pairs in your app across all color modes. That could look like this:
119118

@@ -188,24 +187,22 @@ final class ColorsTests: XCTestCase {
188187
}
189188
```
190189

191-
## 3. UIScrollView extensions to assist with keyboard avoidance
190+
### 3. UIScrollView extensions to assist with keyboard avoidance
192191

193-
`FormViewController` is a view controller with a scrollable content area that will automatically avoid the keyboard for you. It is a good choice for views that have inputs (e.g. login or onboarding). Even for views without inputs, it is still quite useful for managing the creation of a `UIScrollView` and a `contentView` set within it, so that you can focus on your content and not have to code a scrollView for every view.
192+
#### `FormViewController` is a view controller with a scrollable content area that will automatically avoid the keyboard for you. It is a good choice for views that have inputs (e.g. login or onboarding). Even for views without inputs, it is still quite useful for managing the creation of a `UIScrollView` and a `contentView` set within it, so that you can focus on your content and not have to code a scrollView for every view.
194193

195194
<aside>
196195
💡 Almost every full-screen view in your app that contains any text should be a scroll view because of the vagaries of localization, Dynamic Type, potentially small screen sizes, and landscape mode support.
197-
198196
</aside>
199197

200-
## `UIScrollview` Extensions
198+
#### `UIScrollview` Extensions
201199

202200
Want to have a scrollview that avoids the keyboard, but you can’t use `FormViewController`? Most of its functionality is a simple extension to `UIScrollView`. You can add keyboard avoidance to any scroll view like so:
203201

204202
```swift
205203
scrollView.registerKeyboardNotifications()
206204
```
207205

208-
209206
Installation
210207
----------
211208

0 commit comments

Comments
 (0)