在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
swift 与oc 不同,没有宏的定义就像 oc 可以这样写,直接调用: /* 默认颜色 */ #define RGBCOLOR_HEX(h) RGBCOLOR((((h)>>16)&0xFF), (((h)>>8)&0xFF), ((h)&0xFF)) #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
swift 就要这样写了: /* 默认颜色 */ func RGBColor(r :CGFloat ,g:CGFloat,b:CGFloat) ->UIColor{ return UIColor.init(colorLiteralRed: Float(r / 255.0), green:Float(g / 255.0) , blue:Float (b / 255.0), alpha: 1) } func RGBCOLOR_HEX(h:Int) ->UIColor { return RGBColor(r: CGFloat(((h)>>16) & 0xFF), g: CGFloat(((h)>>8) & 0xFF), b: CGFloat((h) & 0xFF)) } let userBackColor = RGBCOLOR_HEX(h: 0xe6e6e6) let userGreenColor = RGBColor(r: 23.0, g: 146.0, b: 137.0) let userReportButtonColor = RGBCOLOR_HEX(h: 0xF3F3F3)
swift 的调用方法: class ConstController: UIViewController {
|
请发表评论