How to set the opacity/alpha of a UIImage?
问题 I know you can do this with a UIImageView, but can it be done to a UIImage? I want to have the animation images array property of a UIImageView to be an array of the same image but with different opacities. Thoughts? 回答1: I just needed to do this, but thought Steven's solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: - (UIImage *)imageByApplyingAlpha:(CGFloat) alpha { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); CGContextRef ctx =