根据UIColor 创建UIImage

CGSize imageSize = CGSizeMake(self.doneButton.frame.size.width, self.doneButton.frame.size.height);

        UIGraphicsBeginImageContextWithOptions(imageSize, 0, [UIScreen mainScreen].scale);

        [[UIColor whiteColor] set];

        UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));

        UIImage *pressedColorImg = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

原文地址:https://www.cnblogs.com/bing-ge/p/4826317.html