Getter for variables #1

Closed
popcorno opened this Issue Nov 23, 2012 · 1 comment

Projects

None yet

2 participants

@popcorno

// I want to be able to get the value of variables.

// Create json file.
{
"Variables": {
"defaultBackgroundColor": "red"
},

"@Controllers": {
    "MyViewController": {
        "UITableView": {
            "backgroundColor": "$defaultBackgroundColor"
        }
    },   
}

}

// UISS init. And appearance is work.
UISS *uiss = [UISS configureWithDefaultJSONFile];
[UISS setSharedUISS:uiss];

// But sometimes I need write code
@implementation MyView

  • (void)drawRect:(CGRect)rect {
    UIColor *color = [[UISS sharedUISS] colorForVariable:@"defaultBackgroundColor"];

    UIBezierPath* bezier = [UIBezierPath bezierPath];
    // ... my bezier code
    [color setFill];
    [bezier fill];
    }

@end

// Other UISS methods

  • (id)valueForVariable:(NSString *)name;
  • (UIColor *)colorForVariable:(NSString *)name;
  • (UIFont *)fontForVariable:(NSString *)name;
  • (UIImage *)imageForVariable:(NSString *)name;
@robertwijas
Owner

You can achieve this by adding UIAppearance property to your class.
Here is an example: https://github.com/robertwijas/UISS/blob/master/Project/UISSDemo/Classes/UISSCustomView.h.

@robertwijas robertwijas was assigned Dec 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment