mirror of https://github.com/SnapKit/SnapKit
Update docs
This commit is contained in:
parent
3b2ee222d7
commit
41c5a71844
79
docs.md
79
docs.md
|
@ -6,12 +6,8 @@ id: docs
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+
|
- iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+
|
||||||
- Xcode 8.0+
|
- Xcode 9.0+
|
||||||
- Swift 3.0+
|
- Swift 4.0+
|
||||||
|
|
||||||
## Migration Guides
|
|
||||||
|
|
||||||
- [SnapKit 3.0 Migration Guide](https://github.com/SnapKit/SnapKit/blob/master/Documentation/SnapKit%203.0%20Migration%20Guide.md)
|
|
||||||
|
|
||||||
## Communication
|
## Communication
|
||||||
|
|
||||||
|
@ -32,7 +28,7 @@ id: docs
|
||||||
$ gem install cocoapods
|
$ gem install cocoapods
|
||||||
```
|
```
|
||||||
|
|
||||||
> CocoaPods 1.1.0+ is required to build SnapKit 3.0.0+.
|
> CocoaPods 1.1.0+ is required to build SnapKit 4.0.0+.
|
||||||
|
|
||||||
To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`:
|
To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`:
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ platform :ios, '10.0'
|
||||||
use_frameworks!
|
use_frameworks!
|
||||||
|
|
||||||
target '<Your Target Name>' do
|
target '<Your Target Name>' do
|
||||||
pod 'SnapKit', '~> 3.0'
|
pod 'SnapKit', '~> 4.0'
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -66,7 +62,7 @@ $ brew install carthage
|
||||||
To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`:
|
To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`:
|
||||||
|
|
||||||
```ogdl
|
```ogdl
|
||||||
github "SnapKit/SnapKit" ~> 3.0
|
github "SnapKit/SnapKit" ~> 4.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project.
|
Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project.
|
||||||
|
@ -306,24 +302,47 @@ func changeButtonPosition() {
|
||||||
|
|
||||||
`topLayoutGuide.snp.bottom` is similar to `topLayoutGuide.bottomAnchor` and you can also use `bottomLayoutGuide.snp.top` to align view on top of UITabBar.
|
`topLayoutGuide.snp.bottom` is similar to `topLayoutGuide.bottomAnchor` and you can also use `bottomLayoutGuide.snp.top` to align view on top of UITabBar.
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
import SnapKit
|
import SnapKit
|
||||||
|
|
||||||
class MyViewController: UIVewController {
|
class MyViewController: UIVewController {
|
||||||
|
|
||||||
lazy var tableView = UITableView()
|
lazy var tableView = UITableView()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
self.view.addSubview(tableView)
|
self.view.addSubview(tableView)
|
||||||
tableView.snp.makeConstraints { (make) -> Void in
|
tableView.snp.makeConstraints { (make) -> Void in
|
||||||
make.top.equalTo(topLayoutGuide.snp.bottom)
|
make.top.equalTo(topLayoutGuide.snp.bottom)
|
||||||
make.left.equalTo(view)
|
make.left.equalTo(view)
|
||||||
make.right.equalTo(view)
|
make.right.equalTo(view)
|
||||||
make.bottom.equalTo(bottomLayoutGuide.snp.top)
|
make.bottom.equalTo(bottomLayoutGuide.snp.top)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Snap view to safe layout guide
|
||||||
|
|
||||||
|
Just like `topLayoutGuide` and `bottomLayoutGuide` using iPhone X's new `safeAreaLayoutGuide` is easy:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import SnapKit
|
||||||
|
|
||||||
|
class MyViewController: UIVewController {
|
||||||
|
|
||||||
|
lazy var tableView = UITableView()
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
self.view.addSubview(tableView)
|
||||||
|
tableView.snp.makeConstraints { (make) -> Void in
|
||||||
|
make.top.equalTo(safeAreaLayoutGuide.snp.bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue