Slide 1

Slide 1 text

Attractive things work better… When you wash and wax a car, it drives better, doesn’t it? Or at least feels like it does. David A. Norman

Slide 2

Slide 2 text

Attractive things work better… When you wash and wax a car, it drives better, doesn’t it? Or at least feels like it does. David A. Norman

Slide 3

Slide 3 text

Robert Wijas

Slide 4

Slide 4 text

Robert Wijas

Slide 5

Slide 5 text

Robert Wijas

Slide 6

Slide 6 text

Robert Wijas

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

UIAppearance on Steroids UISS

Slide 10

Slide 10 text

Quick introduction UIAppearance

Slide 11

Slide 11 text

Protocols @protocol UIAppearance ! + (id)appearance; ! + (id)appearanceWhenContainedIn:(Class )ContainerClass, ... NS_REQUIRES_NIL_TERMINATION; ! @end ! ! @protocol UIAppearanceContainer @end

Slide 12

Slide 12 text

Properties - (void)setProperty:(PropertyType)property forAxis1:(IntegerType)axis1 axisN:(IntegerType)axisN; ! - (PropertyType)propertyForAxis1:(IntegerType)axis1 axisN:(IntegerType)axisN; #define UI_APPEARANCE_SELECTOR

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

[[UIButton appearance] setTitleColor:[[UIColor whiteColor] colorWithAlphaComponent:0.800] forState:UIControlStateNormal]; [[UIButton appearance] setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; [[UIButton appearance] setBackgroundImage:[[UIImage imageNamed:@"button-background-normal"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 10.0, 0.0, 10.0)] forState:UIControlStateNormal]; [[UIButton appearance] setBackgroundImage:[[UIImage imageNamed:@"button-background-highlighted"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 10.0, 0.0, 10.0)] forState:UIControlStateHighlighted]; [[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@"Copperplate-Bold" size:18.0]]; [[UIButton appearance] setTitleEdgeInsets:UIEdgeInsetsMake(1.0, 0.0, 0.0, 0.0)];

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

UISS JSON Syntax

Slide 17

Slide 17 text

UISS JSON Syntax "UIButton":{ "titleColor:normal":["white", 0.8], "titleColor:highlighted":"white", ! "backgroundImage:normal": ["button-background-normal", [0,10,0,10]], "backgroundImage:highlighted": ["button-background-highlighted", [0,10,0,10]], ! "titleEdgeInsets": [1,0,0,0], ! "UILabel":{ "font":["Copperplate-Bold", 18] } }

Slide 18

Slide 18 text

"UIButton":{ "titleColor:normal":["white", 0.8], "titleColor:highlighted":"white", ! "backgroundImage:normal": ["button-background-normal", [0,10,0,10]], "backgroundImage:highlighted": ["button-background-highlighted", [0,10,0,10]], ! "titleEdgeInsets": [1,0,0,0], ! "UILabel":{ "font":["Copperplate-Bold", 18] } } UIAppearance objects and containment

Slide 19

Slide 19 text

"UIButton":{ "titleColor:normal":["white", 0.8], "titleColor:highlighted":"white", ! "backgroundImage:normal": ["button-background-normal", [0,10,0,10]], "backgroundImage:highlighted": ["button-background-highlighted", [0,10,0,10]], ! "titleEdgeInsets": [1,0,0,0], ! "UILabel":{ "font":["Copperplate-Bold", 18] } } Properties

Slide 20

Slide 20 text

"UIButton":{ "titleColor:normal":["white", 0.8], "titleColor:highlighted":"white", ! "backgroundImage:normal": ["button-background-normal", [0,10,0,10]], "backgroundImage:highlighted": ["button-background-highlighted", [0,10,0,10]], ! "titleEdgeInsets": [1,0,0,0], ! "UILabel":{ "font":["Copperplate-Bold", 18] } } Axis parameters

Slide 21

Slide 21 text

"clear" [UIColor clearColor] ! ["#ffffff", 0.5] [UIColor colorWithRed:255.0f green:255.0f blue:255.0f alpha:0.5f] ! [0, 255, 255, 0.5] [UIColor colorWithRed:0.0f green:255.0f blue:255.0f alpha:0.5f] Colors

Slide 22

Slide 22 text

14 [UIFont systemFontOfSize:14.0f] ! ["bold", 14] [UIFont boldSystemFontOfSize:14.0f] ! ["Georgia-Italic", 12] [UIFont fontWithName:@"Georgia-Italic" size:12.0f] Fonts

Slide 23

Slide 23 text

"imageName" [UIImage imageNamed:@"imageName"] ! ["imageName", 1, 2, 3, 4] [[UIImage imageNamed:@"imageName"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 2, 3, 4)] Images

Slide 24

Slide 24 text

"UINavigationBar":{ "Phone":{ "tintColor":"gray" }, "Pad":{ "tintColor":"lightGray" } } UI Idiom Branches

Slide 25

Slide 25 text

"Variables":{ "tint":"blue", “toolbar”:{ "tintColor": "$tint" } }, "UINavigationBar":{ "tintColor": "$tint" }, "UITabBar":{ "tintColor": "$tint" }, "UIToolbar":”$toolbar” Variables

Slide 26

Slide 26 text

"UISSDemoViewController":{ "-UIButton":{ "titleColor:normal":["white", 0.8], "titleColor:highlighted":"white" } } Comments

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Simple Setup

Slide 30

Slide 30 text

one line of code Simple Setup

Slide 31

Slide 31 text

Simple Setup [UISS configureWithDefaultJSONFile]; uiss.json

Slide 32

Slide 32 text

How to make it really cool?

Slide 33

Slide 33 text

How to make it really cool? Live updates

Slide 34

Slide 34 text

Remote Style [UISS configureWithDefaultJSONFile]

Slide 35

Slide 35 text

Remote Style [UISS configureWithURL:[NSURL URLWithString:@"http://localhost/uiss.json"]]

Slide 36

Slide 36 text

How-to Remote uiss.json

Slide 37

Slide 37 text

curl get.pow.cx | sh http://pow.cx

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

UIAppearance - (NSMutableArray *)_appearanceInvocations;

Slide 43

Slide 43 text

Swizzling TaggingAppearanceGeneralSetterIMP ()

Slide 44

Slide 44 text

When the magic happens

Slide 45

Slide 45 text

[UIView(Hierarchy) addSubview:] When the magic happens

Slide 46

Slide 46 text

- (void)reloadAppearance { NSArray * windows = [UIApplication sharedApplication].windows; for (UIWindow *window in windows) { for (UIView *view in window.subviews) { [view removeFromSuperview]; [window addSubview:view]; } } } Reload appearance

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

UIAppearance weakness Selectors

Slide 49

Slide 49 text

subclassing UIAppearance weakness Selectors

Slide 50

Slide 50 text

subclassing UIAppearance weakness custom properties Selectors

Slide 51

Slide 51 text

Alternatives

Slide 52

Slide 52 text

Alternatives

Slide 53

Slide 53 text

Alternatives https://github.com/tombenner/nui

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Layout

Slide 57

Slide 57 text

Layout Auto

Slide 58

Slide 58 text

attribute1 == multiplier × attribute2 + constant

Slide 59

Slide 59 text

attribute1 == multiplier × attribute2 + constant >= <= Left Right Top Bottom Leading Trailing Width Height CenterX CenterY Baseline Left Right Top Bottom Leading Trailing Width Height CenterX CenterY Baseline @500

Slide 60

Slide 60 text

ASCII Art

Slide 61

Slide 61 text

|-[find]-[findNext]-[findField(>=20)]-| ASCII Art

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Why bother?

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

http://github.com/robertwijas/UISS CocoaPods

Slide 70

Slide 70 text

inspired by @worrydream

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

robertwijas