0

I have a image and i mask this image with another image to make shape.
I just want to change the view background color of Masked image.
I am using [UIColor colorWithPatternImage:maskedImage];
But its not working.
Please suggest me how to merge or create Masked 2 images in 1 image so colorWithPatternImage will work.

Artem Shmatkov
  • 1,434
  • 5
  • 22
  • 41
San007
  • 762
  • 1
  • 9
  • 30
  • Is it a pattern? Create a bitmap image context, clip the context to your mask, draw image, create image from your bitmap context – nielsbot Apr 05 '13 at 12:18
  • Actually for the Painting i am creating the mask image to paint in shape only After painting done i have one another view with same blank image so i have to change that image color with painted image. – San007 Apr 05 '13 at 12:21
  • Show your code. Otherwise, there's no way to know why it's not working. – omz Apr 05 '13 at 12:53

2 Answers2

0

Are you assigning the value of

 [UIColor colorWithPatternImage:maskedImage]; 

to anything? Like...

  self.maskedView.backgroundColor = [UIColor colorWithPatternImage:maskedImage]; 
codeqi
  • 753
  • 1
  • 6
  • 14
0
UIImage *originalImage = [UIImage imageNamed:@"original.png"]; //my background image
UIImage *maskedImage       = [UIImage imageNamed:@"maskedImage.png"]; //my masked image

CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );


[originalImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];


[maskedImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.6];

UIImage *newMaskedBackGroundImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

then use this newMaskedBackGroundImage, ex. [UIColor colorWithPatternImage:newMaskedBackGroundImage];

BhushanVU
  • 3,455
  • 1
  • 24
  • 33