UI中对于选择主题的处理方法-创新互联

- (instancetype)init

成都创新互联公司专业为企业提供东营区网站建设、东营区做网站、东营区网站设计、东营区网站制作等企业网站建设、网页设计与制作、东营区企业网站模板建站服务,十载东营区做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

{

  self = [super init];

  if (self) {//初始化_themeName

     

      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

      NSString *key = [defaults objectForKey:KThemeDefaultKey];

      if (key.length == 0) {

         

          _themeName = @"New PinkPink";

       

      } else{

            _themeName = key;

      }

      //获取文件路径

        NSString *filePath = [[NSBundle mainBundle]pathForResource:@"theme" ofType:@"plist"];

      //初始化_themeConfiger

      _themeConfiger = [NSDictionary dictionaryWithContentsOfFile:filePath];

     

      //取得状态栏状态

      [self initTabBarStyle];

  }

  return self;

}

//创建单例

+ (ThemeManager *)shareThemeManage{

 

  static dispatch_once_t onceToken;

  dispatch_once(&onceToken, ^{

      themeManage = [[ThemeManager alloc]init];

  });

  return themeManage;

}

//根据p_w_picpathName返回图片

- (UIImage *)themeImageWithImageName:(NSString *)p_w_picpathName{

 

  //获取文件路径

  NSString *themePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingFormat:@"/%@/%@",_themeConfiger[_themeName],p_w_picpathName];

  return [UIImage p_w_picpathWithContentsOfFile:themePath];

}

//根据textcolorName返回颜色

- (UIColor *)textColorWithTextColorName:(NSString *)textcolorName{

 

  //获取文件路径

  NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingFormat:@"/%@/config.plist",_themeConfiger[_themeName]];

  NSDictionary *dicTheme = [NSDictionary dictionaryWithContentsOfFile:filePath];

 

  NSDictionary *dicColor = dicTheme[textcolorName];

  //设置透明度

  NSInteger alpha = dicColor.count >= 4 ? [[dicColor objectForKey:@"alpha"] integerValue]: 1;

  return [UIColor colorWithRed:[[dicColor objectForKey:@"R"] floatValue] / 255 green:[[dicColor objectForKey:@"G"] floatValue] / 255 blue:[[dicColor objectForKey:@"B"] floatValue] / 255 alpha:alpha];

}

- (void)setThemeName:(NSString *)themeName{

 

  if (_themeName != themeName) {

      _themeName = themeName;

 

      [self initTabBarStyle];

     

      //修改数据

      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

      [defaults setObject:_themeName forKey:KThemeDefaultKey];

      [defaults synchronize];

      //发出通知

      [[NSNotificationCenter defaultCenter]postNotificationName:NotificationTheme object:nil];

  }

}

- (void)initTabBarStyle{

 

  //获取文件路径

  NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingFormat:@"/%@/config.plist",_themeConfiger[_themeName]];

  NSDictionary *dicTheme = [NSDictionary dictionaryWithContentsOfFile:filePath];

 

  _tarBarStyle = [[dicTheme objectForKey:@"Statusbar_Style"] integerValue];

}

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


分享题目:UI中对于选择主题的处理方法-创新互联
链接URL:http://cdiso.cn/article/deogjo.html

其他资讯