iOS 换肤工作总结
来源:互联网 发布:淘宝订单编号前13位 编辑:程序博客网 时间:2024/06/07 10:39
这段时间自己的工作是给应用程序换肤。具体的流程如下:
1、根据登录的账号进行判断。如果登录的是申通的账号。要给整个应用程序的皮肤设置为橘黄色。
2、如果登录的是非申通的账号,则给整个应用程序设置为绿色。
针对上面的问题,自己的处理办法是这样的。
1、在AppDelegate中设置了一个全局变量
/** * 公司 */@property(nonatomic,strong)NSString *brand;2、然后在application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions给brand赋初值
//判断是否是申通 并进行全局的赋值 NSString *company = [[NSUserDefaults standardUserDefaults] objectForKey:@"brand"]; if ([company isEqualToString:@"sto"]) { self.brand = company; }3、创建一个工具类,用于加载相应地图片
//// CZQSkinTool.m// KuaiDiYuan_S//// Created by KuaidiHelp on 15/3/27.// Copyright (c) 2015年 KuaidiHelp. All rights reserved.//#import "CZQSkinTool.h"#import "AppDelegate.h"@implementation CZQSkinToolstatic NSString *_skin;+ (void)initialize{ //加载沙盒中的皮肤 _skin = [[NSUserDefaults standardUserDefaults] objectForKey:@"skin"]; if (_skin == nil) { [[NSNotificationCenter defaultCenter] addObserverForName:@"loginSuccess" object: nil queue:nil usingBlock:^(NSNotification *note) { if([ note.object isEqualToString:@"sto"]){ _skin = @"Orange"; NSLog(@"橘黄色"); }else{ _skin = @"Other"; NSLog(@"绿色"); } }];//------------------------------------------------------------------------------ AppDelegate *myDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; if([myDelegate.brand isEqualToString:@"sto"]){ _skin = @"Orange"; NSLog(@"橘黄色"); }else{ _skin = @"Other"; NSLog(@"绿色"); } }//------------------------------------------------------------------------------ }+ (UIImage *)imageNamed:(NSString *)name{ NSString *image = [NSString stringWithFormat:@"Skins/%@/%@",_skin,name]; return [UIImage imageNamed:image];}@end
4、然后根据这个brand的值 进行相应的换肤
//---------------换肤---------------------//获取全局变量AppDelegate *myDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];//进行判断 如果是申通进行换色if ([myDelegate.brand isEqualToString:@"sto"]) { NSLog(@"-------申通------");}else{ NSLog(@"-------不是申通------");}//---------------换肤---------------------
5、以上步骤,只能用于会再次加载的那些图片。对于已经初始化的,得用通知进行相应地换肤。
NSString *brandChen =[body objectForKey:@"brand" Default:@""]; //登录成功通知大家该干活了 [[NSNotificationCenter defaultCenter] postNotificationName:@"loginSuccess" object:brandChen];
6、在接收到通知后
[[NSNotificationCenter defaultCenter] addObserverForName:@"loginSuccess" object: nil queue:nil usingBlock:^(NSNotification *note) { self.brand = note.object; }];
7、并同时给tabBarController的tabBarItem进行相应地换图片
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(skinForChen:) name:@"loginSuccess" object:nil];
8、skinForChen的相应方法
#if TEST_BUSS //----------------------------业务--------------------------- [self setTabBarItem:self.bussinessVC.tabBarItem NorImage:@"findexpress_tab_21.png" andSelImg:@"findexpress_tab_11.png" notification:no];#endif #if TEST_CAPITAL [self setTabBarItem:self.bussinessVCOther.tabBarItem NorImage:@"findexpress_tab_21.png" andSelImg:@"findexpress_tab_11.png" notification:no];#endif//----------------------------快递圈--------------------------- [self setTabBarItem:self.ecCon.tabBarItem NorImage:@"findbranch_tab_2.png" andSelImg:@"findbranch_tab_1.png" notification:no]; //----------------------------更多--------------------------- [self setTabBarItem:self.moreVC.tabBarItem NorImage:@"more_tab_2.png" andSelImg:@"more_tab_1.png" notification:no];通过以上的步骤,自己相应的完成了App的换肤功能,存在的问题很可能是效率比较低,然后代码有点冗余。不足之处,望指正,已达共同进步的目的。
0 0
- iOS 换肤工作总结
- ios-换肤简单实现
- iOS夜间模式,换肤,换字体样式
- iOS-本地换肤思路
- [Swift 开发] iOS换肤框架 SwiftTheme
- iOS-夜间模式(换肤设置)
- iOS-夜间模式(换肤设置)
- ActiveReports工作总结3——换列打印
- ActiveReports工作总结3——换列打印
- ActiveReports工作总结3——换列打印
- iOS-cocopods换源
- Flex AIR应用换肤功能(Android和IOS)
- iOS开发实用技术之换肤和静态库
- ios「节日换肤」通用技术方案
- iOS【开发之 APP自定义换肤、主题更换】
- 换肤
- 换肤
- 换肤
- opencv:'BYTE' was not declared in this scope
- JavaScript之作用域原理
- ACM训练方案
- linux成长之路(QT Creator 流水帐)
- linux应用开发-信号量互斥编程
- iOS 换肤工作总结
- Java面向对象编程实例(奥特曼打一群小怪兽)
- 编译原理:first集合和follow集合的求法及LL(1)文法判定
- 温固J2EE Servlet
- maven笔记之提要
- HDU3339——In Action
- array,pointer and reference
- hdu 5212 code
- HDU 2019-2020