JJSkin 让您轻松编写界面控件属性。您不必担心当前控件属性是否用于 iPhone、iPad 或不同屏幕尺寸,JJSkin 将帮助您实现。
JJSkin 解决了这些问题。
{
"portrait": {
"stringValue": "1234567890",
"intergerValue": "890",
"floatValue": "234.9",
"boolValue": "1",
"edgeInsets": "{1,2,3,4}",
"rect": "{{5,6},{7,8}}",
"size": "{9,0}",
"color": "#FFc58dd0",
"textLabel": {
"text": "portrait",
"textAlignment": "right",
"lineBreakMode": "clipping"
}
},
"landscape": {
"textLabel": {
"text": "landscape",
"textAlignment": "center",
}
}
}
其次将 JJSkin/JJSkin 拖到您的项目中,并导入 "JJSkin.h"。
第三,获取或更新对象属性。
/**
ID is json label path linked by dot.
ID begins "R" and exclude root label, "portrait" and "landscape".
*/
NSString *stringValue = [JJSkinManager getStringByID:@"R.stringValue"];
CGFloat floatValue = [JJSkinManager getFloatByID:@"R.floatValue"];
CGRect rect = [JJSkinManager getRectByID:@"R.rect"];
/**
Create UILabel object.
In portrait screen, label text is "portrait", and text Alignment is right.
In landscapt screen, label text is "landscape", and text Alignment is center.
*/
UILabel *label = [JJSkinManager getLabelByID:@"R.textLabel"];
/**
Update existed UILable object.
label1 has the same property with label.
*/
UILabel *label1 = [[UILabel alloc] init];
[JJSkinManager updateLabel:label1 withID:@"R.textLabel"];
@interface JJLabelStyle : JJViewStyle
@property (nonatomic, strong) JJFontStyle *fontStyle;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, copy) NSString *textAlignment;
@property (nonatomic, copy) NSString *lineBreakMode;
@property (nonatomic, copy) NSString *numberOfLines;
@property (nonatomic, strong) UIColor *highlightedTextColor;
@end
"textLabel": {
"text": "portrait", // Must same with JJLabelStyle text property name
"textAlignment": "right",
"lineBreakMode": "clipping"
}
+ (id)getObjectByID:(NSString *)id withStyleClass:(Class)styleClass;
+ (void)updateObject:(id)object withID:(NSString *)id withStyleClass:(Class)styleClass;
当您调用 JJSkinManager API 获取对象时,JJSkin 将从第一个文件中分析样式值。如果 JJSkin 没有获取所有样式属性,它将分析下一个文件。
在一个文件中,包含纵向和横向的根标签。如果界面的方向是纵向,JJSkin 只分析纵向的根标签。如果界面方向是横向,JJSkin 将首先分析横向的根标签。如果 JJSkin 没有获取所有样式值,它将继续分析纵向的根标签。
请注意,如果 JJSkin 有 "status" 标签,并且其值为 "finish",则它将不会继续分析。如果值是 "finishIncludeSon",则 JJSkin 不会分析子样式值。
JJSkin 在 MIT 许可下发布。请参阅 LICENSE。
有问题?请创建一个问题!