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

iOS Autolayouts

iOS Autolayouts

Avatar for Kostya Bychkov

Kostya Bychkov

October 31, 2015

Other Decks in Programming

Transcript

  1. Springs & Struts Pros easy to understand how it works

    and easy to debug works really fast
  2. Springs & Struts Cons messy to work with complex dynamic

    layouts imperative different devices screen sizes adds more complexity to implementation
  3. attribute1 = multiplier * attribute2 + constant attribute1 >= multiplier

    * attribute2 + constant attribute1 <= multiplier * attribute2 + constant
  4. attribute1 = multiplier * attribute2 + constant @ priority attribute1

    >= multiplier * attribute2 + constant @ priority attribute1 <= multiplier * attribute2 + constant @ priority
  5. Content Hugging / Compression Resistance override func intrinsicContentSize() -> CGSize

    { return CGSize( width: 320, height: UIViewNoIntrinsicMetric) }
  6. Intrinsic content size width = 200 height = 400 Transforms

    to set of constraints H:[view(>=200@(Compression Resistance Priority))] H:[view(<=200@(Hugging Priority))] V:[view(>=400@(Compression Resistance Priority))] V:[view(<=400@(Hugging Priority))]
  7. Debug Session command alias objcpo po -l objc++ -O --

    command alias objcexpr expr -l objc++ -O -- po view.performSelector(_autolayoutTrace) objcpo [[UIWindow keyWindow] _autolayoutTrace] // prints layouts ambiguity objcpo [view constraintsAffectingLayoutForAxis:0] // horizontal objcpo [view constraintsAffectingLayoutForAxis:1] // vertical [view hasAmbiguousLayout] // BOOL [view exerciseAmbiguityInLayout] // visualizing ambiguity expr (void)[CATransaction flush] Facebook/Chisel
  8. QA