Skip to content

cpthooch/AMUIStylist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMUIStylist

Native declarative styling facilities for UIKit components. AMUIStylis styles are essentially collections of selector invocations recorded over special proxy object, and easily applicable to any other compatible UIKit (actually Cocoa) object.

Capabilities

Declarative way of styling UI elements.

Forget about

someButton.backgroundColor = kGreenColor;

Use semantic style names

someButton.am_style = @"awesome-action-button";

Single style assignment instead of a bunch of settings, e.g. above example may effectively equal to

[someButton setBackgroundColor:[UIColor greenColor]];
[someButton setTitleColor:[UIColor darkTextColor] forState:UIControlStateNormal];
[someButton setImage:[UIImage imageNamed:@"awesome-button"] forState:UIControlStateNormal];
...

Single style may be applied to several objects

someButton.am_style = @"awesome-action-button";
otherButton.am_style = @"awesome-action-button";
loginButton.am_style = @"awesome-action-button";

Singe object may have several styles, applied consequently

someButton.am_style = @"large-text, awesome-action-button";

am_style is KVC compliant property so it can be set directly via Interface Builder

style_ib

Styling can be applied to nearly every Cocoa object

NSMutableDictionary *dullDictStyle = style(NSMutableDictionary.self);
[dullDictStyle setObject:@YES forKey:@"Am I dull?"];

Style definitions support code completion

completion

Styles support inheritance

This will produce combined style from inputFieldStyle settings plus setSecureTextEntry

UITextField *passwordFieldStyle = style(UITextField.self, inputFieldStyle);
[passwordFieldStyle setSecureTextEntry:YES];

Styles organized into style sheets which support hot switching

[AMUIStylist sharedStylist].styleSheet = [AMUIStyleSheet getSheet:@"swag"];

preview

For more examples please take a look at included demo app and test cases.

Launching demo app

To install dependencies:

cd Example
pod install

Open AMUIStylistExample.xcworkspace with Xcode and hit Run.

Dependencies

Currently AMUIStylist depends on:

Unit tests require:

TODO

  1. Get rid of library dependencies.
  2. Create podspec.

Releases

No releases published

Packages

No packages published