Skip to content

Instantly share code, notes, and snippets.

@mike-anderson
Created August 14, 2013 04:35
Show Gist options
  • Save mike-anderson/6228041 to your computer and use it in GitHub Desktop.
Save mike-anderson/6228041 to your computer and use it in GitHub Desktop.
Allows setting nativeCSS (nativecss.com) id and class as user defined runtime attributes in interface builder.
#import <UIKit/UIKit.h>
#import "UIView+NativeCSS.h"
@interface UIView (NativeCSSIBShim)
@property (nonatomic,weak) NSString *nativeCSSId;
@property (nonatomic,weak) NSString *nativeCSSClass;
@end
#import "UIView+NativeCSSIBShim.h"
@implementation UIView (NativeCSSIBShim)
- (void) setNativeCSSClass:(NSString *)CSSClass
{
NSArray *classes = [self CSSClasses];
for (NSString *class in classes) {
[self removeCSSClass:class];
}
classes = [CSSClass componentsSeparatedByString:@" "];
for (NSString *class in classes) {
[self addCSSClass:class];
}
}
- (NSString *) nativeCSSClass
{
NSString *classes;
for (NSString *class in [self CSSClasses]) {
classes = [classes stringByAppendingFormat:@" %@",class ];
}
return classes;
}
- (void) setNativeCSSId:(NSString *)NativeCSSId
{
[self setCSSId:NativeCSSId];
}
- (NSString *) nativeCSSId
{
return [self CSSId];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment