1

I don't know whether it sounds silly,

I have an image which will be added in the UIImageView or an UIButton. That image contains some texts in the Red color and the background is black. Is it possible to change the BG color as well as the Text color to custom color. Is that possible ??

2
  • Are you looking for the one as in [this link][1] ? [1]: stackoverflow.com/questions/1117211/… Commented Jul 9, 2012 at 7:08
  • It is like a tint. It doesn't actually change the color right ? Commented Jul 9, 2012 at 7:24

2 Answers 2

3

If, after considering George's answer, you still need to modify the colours, you could try using Core Image filters.

The following example adjusts the hue of a UIImageView called screenImage by an angle given in angle.

- (void)rebuildFilterChain:(double)angle {
  UIImage *uiImage = [UIImage imageNamed:@"background.jpg"];
  CIImage *image = [CIImage imageWithCGImage:[uiImage CGImage]];

  CIFilter *hueAdjust = [CIFilter filterWithName:@"CIHueAdjust"];
  [hueAdjust setDefaults];
  [hueAdjust setValue:image forKey: @"inputImage"];
  [hueAdjust setValue: [NSNumber numberWithFloat:angle] forKey: @"inputAngle"];
  self.resultImage = [hueAdjust valueForKey: @"outputImage"];

  CGImageRef cgImage = [context createCGImage:resultImage fromRect:resultImage.extent];
  screenImage.image = [UIImage imageWithCGImage:cgImage];
  CGImageRelease(cgImage);
}

The full list of Core Image filters is on the Apple site.

Sign up to request clarification or add additional context in comments.

Comments

1

Why do you use an image? If you have a background color that means you are using a flat color...not an image actually. So you can set the background color of the button as well as the title color. If you are doing this just to have rounded corners , don't. Just import <QuartzCore/QuartzCore.h> and do this:

button.layer.cornerRadius = 8;

button.layer.masksToBounds = TRUE;

Hope this helps.

Cheers!

1 Comment

Thank you. Actually, I am having an image which consists of the text (like glittering) of height 50. And I don't know which font they are using. Looks stlyish. That text color is Red. I am thinking , whether it is possible to change that particular text color in that image. That is places in a UIImageView.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.