项目作者: cpthooch

项目描述 :
Native styling facilities for UIKit components.
高级语言: Objective-C
项目地址: git://github.com/cpthooch/AMUIStylist.git
创建时间: 2017-03-06T12:18:12Z
项目社区:https://github.com/cpthooch/AMUIStylist

开源协议:MIT License

下载


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

  1. someButton.backgroundColor = kGreenColor;

Use semantic style names

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

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

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

Single style may be applied to several objects

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

Singe object may have several styles, applied consequently

  1. 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

  1. NSMutableDictionary *dullDictStyle = style(NSMutableDictionary.self);
  2. [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

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

Styles organized into style sheets which support hot switching

  1. [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:

  1. cd Example
  2. 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.