ios 更换皮肤思路和代码

阅读更多

 

首先定义一个宏:#define kMyColor(tempColor)    [UIColor colorWithHexString:[[kUserDefault objectForKey:@"kAllColorDict"]objectForKey:tempColor] alpha:1.0f]

#define kRgbColor(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]

 

整体的色值就这些方法就ok了。。。。具体程序里面的图片按钮,同样道理。。

 

 

在程序运行的时候调用:

#pragma mark=====更换皮肤=======

-(void)changeAllColor{

    if (![kUserDefault boolForKey:@"firstLanch"]) {

        NSMutableDictionary *allColorDict = [NSMutableDictionarydictionary];

        [allColorDict setObject:@"#f4f4f4"forKey:@"kBackgroundColor"];//背景。

        [allColorDict setObject:@"#4EBC51" forKey:@"kHostColor"];//主色调。

        [allColorDict setObject:@"#4EBC51" forKey:@"kNaviColor"];//导航条色

        [allColorDict setObject:@"#121212"forKey:@"kNaviTitleColor"];//导航条字体色。

        

        [kUserDefault setObject:allColorDict forKey:@"kAllColorDict"];

        [kUserDefault synchronize];

        [kUserDefault setBool:YES forKey:@"firstLanch"];

    }

 

}

 

 

在调用换肤方法里面:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

 

    if (buttonIndex == 0) {//默认浅绿色

        NSMutableDictionary *allColorDict = [NSMutableDictionarydictionary];

        [allColorDict setObject:@"#f4f4f4"forKey:@"kBackgroundColor"];//背景。

        [allColorDict setObject:@"#4EBC51" forKey:@"kHostColor"];//主色调。

        [allColorDict setObject:@"#4EBC51" forKey:@"kNaviColor"];//导航条色

        [allColorDict setObject:@"#121212"forKey:@"kNaviTitleColor"];//导航条字体色。

        

        [kUserDefault setObject:allColorDict forKey:@"kAllColorDict"];

        [kUserDefault synchronize];

    }else if (buttonIndex == 1){//天蓝色

        NSMutableDictionary *allColorDict = [NSMutableDictionarydictionary];

        [allColorDict setObject:@"#f4f4f4"forKey:@"kBackgroundColor"];//背景。

        [allColorDict setObject:@"#03A9F4" forKey:@"kHostColor"];//主色调。

        [allColorDict setObject:@"#03A9F4" forKey:@"kNaviColor"];//导航条色

        [allColorDict setObject:@"#121212"forKey:@"kNaviTitleColor"];//导航条字体色。

        

        [kUserDefault setObject:allColorDict forKey:@"kAllColorDict"];

        [kUserDefault synchronize];

    }else if(buttonIndex == 2){///浅青色

        NSMutableDictionary *allColorDict = [NSMutableDictionarydictionary];

        [allColorDict setObject:@"#f4f4f4"forKey:@"kBackgroundColor"];//背景。

        [allColorDict setObject:@"#00BCD4" forKey:@"kHostColor"];//主色调。

        [allColorDict setObject:@"#00BCD4" forKey:@"kNaviColor"];//导航条色

        [allColorDict setObject:@"#121212"forKey:@"kNaviTitleColor"];//导航条字体色。

        

        [kUserDefault setObject:allColorDict forKey:@"kAllColorDict"];

        [kUserDefault synchronize];

    }else if(buttonIndex == 3){///紫罗兰

        NSMutableDictionary *allColorDict = [NSMutableDictionarydictionary];

        [allColorDict setObject:@"#f4f4f4"forKey:@"kBackgroundColor"];//背景。

        [allColorDict setObject:@"#9C27B0" forKey:@"kHostColor"];//主色调。

        [allColorDict setObject:@"#9C27B0" forKey:@"kNaviColor"];//导航条色

        [allColorDict setObject:@"#121212"forKey:@"kNaviTitleColor"];//导航条字体色。

        

        [kUserDefault setObject:allColorDict forKey:@"kAllColorDict"];

        [kUserDefault synchronize];

    }

 

 

}

你可能感兴趣的:(ios换肤,ios更换皮肤,ios不同颜色,颜色,变色)