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中对于选择主题的处理方法-创新互联
网页路径:https://www.cdcxhl.com/article20/deogjo.html

成都网站建设公司_创新互联,为您提供Google云服务器搜索引擎优化用户体验微信公众号企业网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设