10

我知道一个面具添加了类似的东西

UIImageView *mask = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mask.png"]];
[mask setFrame:kHexagonMaskRect];
[self setBackgroundColor:kBackgroundColor];
[self layer].mask = [mask layer];
[mask release];

但是我该如何删除它?将其设置为 nil 有效,但这是泄漏的。

4

1 回答 1

23
#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;

希望对你有帮助..

于 2012-05-04T08:30:19.533 回答