iOS skin-changing ideas, and tools

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.