UIColor+Hex

来源:互联网 发布:mac用什么免费办公软件 编辑:程序博客网 时间:2024/06/04 20:42
#import <UIKit/UIKit.h>    @interface UIColor (Hex)    + (UIColor *)colorWithHex:(long)hexColor;  + (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity;    @end      #import "UIColor+Hex.h"    @implementation UIColor (Hex)    + (UIColor*) colorWithHex:(long)hexColor;  {      return [UIColor colorWithHex:hexColor alpha:1.];      }    + (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity  {      float red = ((float)((hexColor & 0xFF0000) >> 16))/255.0;      float green = ((float)((hexColor & 0xFF00) >> 8))/255.0;      float blue = ((float)(hexColor & 0xFF))/255.0;      return [UIColor colorWithRed:red green:green blue:blue alpha:opacity];    }       @end  

0 0
原创粉丝点击