画出背景图
2015-12-29 本文已影响58人
MindTheGap
好久没用了。
CGSize imageSize = CGSizeMake(50, 50);
UIGraphicsBeginImageContextWithOptions(imageSize, 0, [UIScreen mainScreen].scale);
[[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1] set];
UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));
UIImage *pressedColorImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[btn setBackgroundImage:pressedColorImg forState:UIControlStateHighlighted];
无需添加纯色图片文件,为button设置高亮背景,Do it like this . 妈妈再也不用担心了。