Upgrade to Pro — share decks privately, control downloads, hide ads and more …

カジュアルにはじめるVFL / Let's start VFL

カジュアルにはじめるVFL / Let's start VFL

AKIBA.swift × エウレカ コードレイアウト勉強会
2018-03-28
https://classmethod.connpass.com/event/81032/

ばんじゅん🍓

March 28, 2018
Tweet

More Decks by ばんじゅん🍓

Other Decks in Programming

Transcript

  1. Α͘ݟ͔͚Δ7'- Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60400009f630 H:[UIImageView:

    0x7fa08ef0b820]-(8)-[UILabel:0x7fa08ef0bba0'Name'] (active)> ੍໿͕ίϯϑϦΫτͨ͠ͱ͖ͷίϯιʔϧϩά ςΩετίϛϡχέʔγϣϯ
  2. override func loadView() { super.loadView() let autolayout = northLayoutFormat(["p": 8],

    [ "icon": iconView, "name": nameLabel]) autolayout("H:|-p-[icon(==64)]") autolayout("H:|-p-[name]-p—|") autolayout("V:|-p—[icon(==64)]-p-[name]") } iconView nameLabel
  3. 7'-ύʔαʔΛͭ͘Δ struct VFL { let orientation: Orientation let firstBound: (Bound,

    Connection)? let firstView: View let views: [(Connection, View)] var lastView: View {return views.last?.1 ?? firstView} let lastBound: (Connection, Bound)?
  4. 7'-ύʔαʔΛͭ͘Δ enum Orientation {case h, v} struct View { let

    name: String let predicateListWithParens: [Predicate] } enum Bound: String { case superview = "|" case layoutMargin = "||" } struct Connection { let predicateList: PredicateList }
  5. 7'-ύʔαʔΛͭ͘Δ enum PredicateList { case simplePredicate(SimplePredicate) case predicateListWithParens([Predicate]) } enum

    SimplePredicate { case metricName(MetricName) case positiveNumber(CGFloat) } enum Relation {case eq, le, ge} enum ObjectOfPredicate { case constant(Constant) case viewName(ViewName) }
  6. 7'-ύʔαʔΛͭ͘Δ enum Constant { case metricName(MetricName) case number(CGFloat) } enum

    Priority { case metricName(MetricName) case number(CGFloat) } struct Predicate { let relation: Relation? let objectOfPredicate: ObjectOfPredicate let priority: Priority? } }