GREAT STUFF
AUTO LAYOUT
CONSTRAINT-BASED DESCRIPTIVE
LAYOUT SYSTEM
Slide 4
Slide 4 text
wtf?
Slide 5
Slide 5 text
IN THE PAST...
THERE WAS HARD-CODED LAYOUT
Slide 6
Slide 6 text
button.frame = CGRectMake(10,10,15,15);
Slide 7
Slide 7 text
the problem:
we’re screwed on device rotation
so we have to ‘manually’ adjust.
Slide 8
Slide 8 text
BUTTON
PORTRAIT
LANDSCAPE
Slide 9
Slide 9 text
wtf?
Slide 10
Slide 10 text
AUTO LAYOUT
t the rescue!
Slide 11
Slide 11 text
GREAT STUFF
DESCRIPTIVE
button1 centered vertically in it’s superview
button1 is at a fixed distance from the top
of my button2
Slide 12
Slide 12 text
GREAT STUFF
CONSTRAINTS
button1.center.y = superview.
button1 is at a fixed distance of my button2
button.center.y = superview.center.y
button1.bottom = button2.top - distance
Slide 13
Slide 13 text
AUTO LAYOUT
SPECIFY CONSTRAINTS AND
iOS CALCULATES FRAMES
AUTOMATICALLY
Slide 14
Slide 14 text
WITH AUTO LAYOYUT
hand on
Slide 15
Slide 15 text
GREAT STUFF
INTERFACE BUILDER
can handle about 90% of what you can do with
auto layout.
overhauled in Xcode 5, less intrusive, more
control.
Slide 16
Slide 16 text
dem ...
Slide 17
Slide 17 text
EXTRA 10%...
the
Slide 18
Slide 18 text
TWO WAYS
..............................................
TO UNLOCK
Slide 19
Slide 19 text
GREAT STUFF
VISUAL LANGUAGE FORMAT
specify your layout using ascii art
Slide 20
Slide 20 text
+1
(›°□°ʣ›ớ ᵲᴸᵲɹᵪᴸᵪ
ascii...
Slide 21
Slide 21 text
GREAT STUFF
CODE SAMPLE
[mybutton]
[mybutton][mybutton2]
[mybutton]-[mybutton]
Slide 22
Slide 22 text
SAMPLE
BUTTON2
BUTTON
VERTICAL
CONSTRAINT
Slide 23
Slide 23 text
how do I code it?
awesome
Slide 24
Slide 24 text
EXAMPLE
V:[button]-[button2]-|
BUTTON2
BUTTON
Slide 25
Slide 25 text
V:[button]-[button2]-|
DEFAULT SUPERVIEW
VERTICAL
Slide 26
Slide 26 text
EXAMPLE
VIEW V:|-[button]-|
H:|-[button]-|
Slide 27
Slide 27 text
one more thing...
Slide 28
Slide 28 text
CENTER A VIEW THAT’S HALF
THE WIDTH & HEIGHT OF
ANOTHER VIEW?
HOW TO