自定义系统Tabbar选择后的图片和字体颜色

来源:互联网 发布:python dateutil 安装 编辑:程序博客网 时间:2024/05/02 10:05

自定义选择图片颜色
 [[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithHexString:@"52b800"]];
自定义选择字体颜色    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary                                      dictionaryWithObjectsAndKeys: [UIColor colorWithHexString:@"52b800"],                         UITextAttributeTextColor, nil] forState:UIControlStateSelected];


附上UIColor延展的2个方法

+ (UIColor *)colorWithRGBHex:(UInt32)hex {int r = (hex >> 16) & 0xFF;int g = (hex >> 8) & 0xFF;int b = (hex) & 0xFF;return [UIColor colorWithRed:r / 255.0f  green:g / 255.0fblue:b / 255.0f  alpha:1.0f];}// Returns a UIColor by scanning the string for a hex number and passing that to +[UIColor colorWithRGBHex:]// Skips any leading whitespace and ignores any trailing characters+ (UIColor *)colorWithHexString:(NSString *)stringToConvert {NSScanner *scanner = [NSScanner scannerWithString:stringToConvert];unsigned hexNum;if (![scanner scanHexInt:&hexNum]) return nil;return [UIColor colorWithRGBHex:hexNum];}




0 0
原创粉丝点击