我知道掩码添加了像
这样的东西UIImageView *mask = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mask.png"]];
[mask setFrame:kHexagonMaskRect];
[self setBackgroundColor:kBackgroundColor];
[self layer].mask = [mask layer];
[mask release];
但我如何删除它?将它设置为nil有效,但这是泄漏。
答案 0 :(得分:20)
#import <QuartzCore/QuartzCore.h>
添加掩码
UIImageView *maskimageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mask.png"]];
CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"mask.png"] CGImage];
maskimageview.layer.mask = mask;
maskimageview.layer.masksToBounds = YES;
删除面具
maskimageview.layer.mask = nil;
希望,这会对你有帮助..