通过一个color创建一个image
使用的地方:
[_addButton setBackgroundImage:[UIImage imageWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.f]] forState:UIControlStateDisabled];
UIImage+Theme.m
==============================
+ (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *bg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return bg; }
使用的地方:
[UIImage imageWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.f]]