Share
Embed
Transcript
18 slides
-
J04 ଁ ీ ࠺ ࢮ ࡦ ࡤ ࡨ ࢊ
ࡹ ࡻ ࢈ ࢢ -
NSLayoutAnchor var leadingAnchor: NSLayoutXAxisAnchor var leftAnchor: NSLayoutXAxisAnchor var centerXAnchor: NSLayoutXAxisAnchor
var rightAnchor: NSLayoutXAxisAnchor var trailingAnchor: NSLayoutXAxisAnchor var topAnchor: NSLayoutYAxisAnchor var centerYAnchor: NSLayoutYAxisAnchor var bottomAnchor: NSLayoutYAxisAnchor var firstBaselineAnchor: NSLayoutYAxisAnchor var lastBaselineAnchor: NSLayoutYAxisAnchor var widthAnchor: NSLayoutDimension var heightAnchor: NSLayoutDimension -
topAnchor │ ▼ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ ▲ ┃ ┃ │ ┃
leadingAnchor ┃heightAnchor ┃ trailingAnchor ──▶┃ │ ┃◀── leftAnchor ┃◀────┼──────widthAnchor────▶┃ rightAnchor ┃ │ ┃ ┃ ▼ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ▲ │ bottomAnchor -
let imageView = UIImageView() let label = UILabel() NSLayoutConstraint.activateConstraints([ imageView.leadingAnchor
.constraintEqualToAnchor(label.leadingAnchor), imageView.bottomAnchor .constraintEqualToAnchor(label.topAnchor, constant: 8.0), ]) │╔══════════════════╗ ║ ║ │║ UIImageView ║ ║ ║ │╚══════════════════╝ — │ │8 — │┌─────────────┐ │ UILabel │ │└─────────────┘ -
UILayoutGuide var leadingAnchor: NSLayoutXAxisAnchor var leftAnchor: NSLayoutXAxisAnchor var centerXAnchor: NSLayoutXAxisAnchor
var rightAnchor: NSLayoutXAxisAnchor var trailingAnchor: NSLayoutXAxisAnchor var topAnchor: NSLayoutYAxisAnchor var centerYAnchor: NSLayoutYAxisAnchor var bottomAnchor: NSLayoutYAxisAnchor var widthAnchor: NSLayoutDimension var heightAnchor: NSLayoutDimension -
let leftLabel = UILabel() let rightLabel = UILabel() let spacer
= UILayoutGuide() view.addLayoutGuide(spacer) NSLayoutConstraint.activateConstraints([ leftLabel.trailingAnchor .constraintEqualToAnchor(spacer.leadingAnchor), rightLabel.leadingAnchor .constraintEqualToAnchor(spacer.trailingAnchor), leftLabel.widthAnchor .constraintEqualToAnchor(spacer.widthAnchor), leftLabel.widthAnchor .constraintEqualToAnchor(rightLabel.widthAnchor), ]) ┏━━━━━━━━━━━━━┳─────────────┳━━━━━━━━━━━━━┓ ┃ UILabel ┃ Guide ┃ UILabel ┃ ┗━━━━━━━━━━━━━┻─────────────┻━━━━━━━━━━━━━┛ | ─ ─ ─ ─ ─ ─ | ─ ─ ─ ─ ─ ─ | ─ ─ ─ ─ ─ ─ | -
UIStackView var axis: UILayoutConstraintAxis // .Horizontal, .Vertical var distribution: UIStackViewDistribution
// .Fill, .FillEqually, .FillProportionally // .EqualSpacing, .EqualCentering var alignment: UIStackViewAlignment // .Fill, .Leading, .Top, .FirstBaseline // .Center, .Trailing, .Bottom, .LastBaseline var spacing: CGFloat -
─────────────────────────────axis────────────────────────────▶ ╔══════════════════════════════════════════════════════════════╗ ║ ┏━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━┓ ║ ║ ┃ —
┃ ┃ ┃ ┃ ┃ ║ ║ ┃ │ ┃ ┃ spacing ┃ ║ ║ ┃ │ ┃ ┃ ┃|──|┃ ┃ ║ ║ ┃ │ ┃ ┃ ┃ ┃ ┃ ║ ║ ┃ alignment ┃ ┃ ┃ ┗━━━━━━━━━━━━━━┛ ║ ║ ┃ │ ┃ ┃ ┃ ║ ║ ┃ │ ┃ ┃|──distribution──|┃ ║ ║ ┃ │ ┃ ┃ ┃ ║ ║ ┃ — ┃ ┃ ┃ ║ ║ ┗━━━━━━━━━━━━━━┛ ┃ ┃ ║ ║ ┃ ┃ ║ ║ ┃ ┃ ║ ║ ┗━━━━━━━━━━━━━━━━━━┛ ║ ╚══════════════════════════════════════════════════════════════╝ -
New Layout Systems • New classes • NSLayoutAnchor • UILayoutGuide
• UIStackView • Great improvements for iOS (OS X)