I searched high and low and finally found a solution with almost no limits. So here you are:
UIImageView *maskeeImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MaskeeImage.png"]]; [maskeeImage setAnimationRepeatCount:-1]; [maskeeImage setAnimationImages:[[NSArray alloc] initWithObjects:[UIImage imageNamed:@"MaskeeImage1.png"], [UIImage imageNamed:@"MaskeeImage2.png"], [UIImage imageNamed:@"MaskeeImage3.png"], nil]]; [maskeeImage startAnimating]; CALayer *maskeeLayer = [maskeeImage layer]; maskeeLayer = CGRectMake(0, 0, 768, 1004); [[[self view] layer] addSublayer:maskeeLayer]; UIImage *maskImage = [UIImage imageNamed:@"ImageMask.png"]; CALayer *maskLayer = [CALayer layer]; maskLayer.contents = (id) myImageMask.CGImage; maskLayer.frame = CGRectMake(0, 0, 768, 1004); [maskeeLayer setMask:maskLayer];
Come here! It is really very simple as soon as you know how to do it. I tried to show a few different options; Using UIImageViews or UIImages, Animations (which can also be used for masks).
To summarize all this, you basically need to set the mask property to your CALayer. Each subclass of UIView has a CALayer attached to it, so you are not limited at all to where you get your mask or disguise from.
Hope this helps. Hi Dylan
source share