Slide 34
Slide 34 text
// leading, trailing
extension UIView {
func edges(equalTo view: UIView, offset: NSDirectionalEdgeInset) {
NSLayoutConstraint.activate([
topAnchor.constraint(equalTo: view.topAnchor, constant: offset.top),
bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -offset.bottom),
leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: offset.leadingAnchor),
trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -offset.trailingAnchor)
])
}
}
余談
leading trailingを使いたいなら
10