IOS制作纯色背景

// 生成纯色背景图
- (UIImage *)createPureColorImageWithColor:(UIColor *)color alpha:(CGFloat)alpha size:(CGSize)size
{
// 纯色的UIView
UIView *pureColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
pureColorView.backgroundColor = color;
pureColorView.alpha = alpha;

// 由上下文获取UIImage
UIGraphicsBeginImageContext(size);
[pureColorView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *pureColorImage = UIGraphicsGetImageFromCurrentImageContext();

// 结束上下文
UIGraphicsEndImageContext();

return pureColorImage;
}

posted @ 2015-10-13 09:34  小毛驴  阅读(523)  评论(0编辑  收藏  举报