iOS 十六进制转RGB

+ (UIColor *)colorWithRGBHex:(UInt32)hex
{
    return [UIColor colorWithRGBHex:hex alpha:1.0f];
}

+ (UIColor *)colorWithRGBHex:(UInt32)hex alpha:(CGFloat)alpha
{
    int r = (hex >> 16) & 0xFF;
    int g = (hex >> 8) & 0xFF;
    int b = (hex) & 0xFF;

    return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:alpha];
}
时间: 2024-10-09 03:37:01

iOS 十六进制转RGB的相关文章

iOS 十六进制的颜色值转换为UIColor

UIColor+Hex.h里面中 #import <UIKit/UIKit.h> @interface UIColor (Hex) + (UIColor *) colorWithHexString: (NSString *)color; @end UIColor+Hex.m里面中 #import "UIColor+Hex.h" @implementation UIColor (Hex) #pragma mark - 颜色转换 iOS中十六进制的颜色转换为UIColor +

ios开发常用RGB色值

iOS中RGB常用的色值,同时可将对颜色的设置定义成宏,方便开发应用,如: // RGB颜色转换(16进制->10进制) #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue

iOS 十六进制的相加取反

ios中将NSstring字符串转换成char类型 NSString *string = [NSString stringWithFormat:@"5D"]; const char *result = [string UTF8String]; char字符转成NSstring char a[10] = "3Er4"; NSString *string = [NSString stringWithUTF8String:a]; 将char类型字符转成十进制类型,然后需要

iOS十六进制和字符串的相互转换

NSString *dictString = [dict JSONFragment];//组合成的. 用这个就行了... dictString==={"content":"Sadgfdfg","phoneno":"","email":"[email protected]"}=== // 十六进制转换为普通字符串的. + (NSString *)stringFromHexString:(N

iOS 十六进制和字符串转换

NSString *dictString = [dict JSONFragment];//组合成的. dictString==={"content":"Sadgfdfg","phoneno":"","email":"[email protected]"}=== // 十六进制转换为普通字符串的. + (NSString *)stringFromHexString:(NSString *)

Color 颜色码-英文名称-十六进制-RGB对照表

  色 英文代码 形像颜色 HEX格式 RGB格式 LightPink 浅粉红 #FFB6C1 255,182,193 Pink 粉红 #FFC0CB 255,192,203 Crimson 猩红 #DC143C 220,20,60 LavenderBlush 脸红的淡紫色 #FFF0F5 255,240,245 PaleVioletRed 苍白的紫罗兰红色 #DB7093 219,112,147 HotPink 热情的粉红 #FF69B4 255,105,180 DeepPink 深粉色 #F

IOS 十六进制字符串转换成UIColor

/** * 十六进制转换成UIColor * * @param stringToConvert 十六进制字符串 * * @return UIColor */ +(UIColor *) hexStringToColor: (NSString *) stringToConvert { NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCha

iOS 导航栏rgb值与设置的有差异

转:http://b2cloud.com.au/how-to-guides/bar-color-calculator-for-ios7-and-ios8/ 计算:http://htmlpreview.github.io/?https://github.com/tparry/Miscellaneous/blob/master/UINavigationBar_UIColor_calculator.html

iOS 十六进制配置背景颜色

给UIColor写一个延展: #import <UIKit/UIKit.h> @interface UIColor (color) + (UIColor*)colorWithHexString:(NSString*)hex; + (UIColor*)colorWithHexString:(NSString*)hex withAlpha:(CGFloat)alpha; @end //  Created by Dubai on 15/4/16. //  Copyright (c) 2015年 Du