lundi 29 décembre 2014

iOS - masking with colorWithPatternImage without repeating on .png file

I'm triying to fill with pattern my mask images (.png)



UIImageView *imageView = (UIImageView*)_maskView.contentView;
imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.tintColor = [UIColor colorWithPatternImage:image];


Now I have done what I want to do. But with a problem. Here is the screenshot:


screenshot


In this screenshot I have these layers back to front;



  1. mainImageView -> contains the waterfall image.

  2. maskView -> lies on the top of the mainImageView. It is a custom UIView. It contains an imageView named contentView.

  3. contentView -> An UIImageView. Subview of maskView. Contains the mask image. I use colorWithPatternImage code on its tintColor.


As you can see, my pattern image is tiling(or repeating or whatever you call).


I tried to resize the pattern image to the size of the imageView also tried resizing to high resolutions like 4000X4000 with no luck.


Tried something like



self.layer.contents = (id)[UIImage imageNamed:@"freshBackground.png"].CGImage;


but this code is filling the entire imageView.


Now I'm out of options. Can anyone help me on this? Thank you.


Aucun commentaire:

Enregistrer un commentaire