implementation principles and ideas : Different kinds of skin under different folders , with a plist file to hold the control background color under different controllers
The plist filename is called the controller name , and the internal data dictionary key value pair customizes a naming convention that is easy to read
//
#import "MYScreenToll.h"
@interface myscreentoll ()
@end
Skin Settings
Static nsstring*_skin;
@implementation Myscreentoll
called when class initialization is loaded
+ (void) Initialize
{
_skin=[[nsuserdefaults standarduserdefaults]objectforkey:@ "Skin1" ];
if (_skin= =Nil) {
_skin=@ "Blue";
}
}
class Method
+ (void) Saveskin: (nsstring*) Skin
{
_skin=skin;
// save
nsuserdefaults *user=[nsuserdefaults standarduserdefaults];
[User SetObject: Skin forkey:@ "Skin1"];
[User synchronize];
}
+ (UIImage*) LoadImage: (nsstring*) imageName
{
nsstring*pathname=[nsstring stringwithformat:@ "skin/%@/%@",_skin, ImageName];
UIImage *image=[UIImage imagenamed:p athname];
return image;
}
+ (uicolor*) Loadcolor: (nsstring*) key
{
// stitching path
nsstring *plistname=[nsstring stringwithformat:@ "Skin/%@/color.plist", _skin];
// read plist file
nsstring*str=[[nsbundle mainbundle]pathforresource:p listname ofType: Nil];
nsdata *data=[nsdata datawithcontentsoffile: str];
nsdictionary *dict=[nsjsonserialization jsonobjectwithdata:d ata options:0 error:NULL];
nsstring*colorstr=[dict objectforkey: key];
nsarray *rgb=[colorstr componentsseparatedbystring:@ ","];
uicolor *col=[[uicolor alloc]initwithred:[rgb[< Span class= "S12" >0] intvalue]/255.0 green:[rgb[1 intvalue]/255.0 blue:[rgb[2 intvalue]/ 255.0 alpha:1
return col;
}
@end
iOS skin-changing ideas, and tools