How can I change the color of a UIImage? [duplicate]

The accepted answer is correct, but there is a much more easy way for UIImageView: Obj-C: UIImage *image = [UIImage imageNamed:@”foo.png”]; theImageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [theImageView setTintColor:[UIColor redColor]]; Swift 2: let theImageView = UIImageView(image: UIImage(named:”foo”)!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)) theImageView.tintColor = UIColor.redColor() Swift 3: let theImageView = UIImageView(image: UIImage(named:”foo”)!.withRenderingMode(.alwaysTemplate)) theImageView.tintColor = UIColor.red

Creating a UIImage from a rotated UIImageView

OK – at last I seem to have done it. Any comments on the correctness would be useful… needed a translate, a rotate, a scale and an offset from the drawing rect position to make it work. Code is here: CGAffineTransform transform = CGAffineTransformIdentity; transform = CGAffineTransformTranslate(transform, boundingRect.size.width/2, boundingRect.size.height/2); transform = CGAffineTransformRotate(transform, angle); transform = … Read more

How to create an image from UILabel?

From: pulling an UIImage from a UITextView or UILabel gives white image. // iOS – (UIImage *)grabImage { // Create a “canvas” (image context) to draw in. UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0); // high res // Make the CALayer to draw in our “canvas”. [[self layer] renderInContext: UIGraphicsGetCurrentContext()]; // Fetch an UIImage of our “canvas”. UIImage *image … Read more