AutoLayout Extensions is the set of codes I use the most.
-
import Extension
Turn on the Xcode, and entering exsiting project.
And then [File] -> [Add Package Dependencies...] -> [Add local] -
Write Import Extensions
import Extensions
- Use Anchor() Like this.
Suppose that you use label in your code like this.
let labelTT : UILabel = {
let lb = UILabel()
lb.text = "hello"
lb.font = UIFont.boldSystemFont(ofSize: 30)
return lb
}()
Usage is followed.
labelTT.anchor(top: view.safeAreaLayoutGuide.topAnchor,
left: view.leftAnchor,
right: view.rightAnchor,
paddingTop: 10,
paddingLeft: 10,
paddingRight: 10)
Others are same.