【发布时间】:2014-07-10 07:16:23
【问题描述】:
我有一个 UIView,其中包含 UIImagesViews 以及从远程服务器加载的图像。
从服务器加载的图像是彩色的。
我想在我的 UIView 上创建一个蒙版,将其所有内容(包括图像)设置为黑白。
但我不想在每张照片准备好时都将蒙版放在上面。
我尝试创建UIView 的子类:
@interface FriezeView : UIView
@property (nonatomic, strong) UIView *mask;
@property (nonatomic, strong) UIView *container;
@end
这个类的init方法:
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
self.container = [[UIView alloc] initWithFrame:frame];
self.mask = [[UIView alloc] initWithFrame:frame];
[self addSubview:self.container];
[self addSubview:self.mask];
}
return self;
}
然后我使用mask UIView 为container UIView 着色。
[_frieze.container addSubview:myImageView];
_frieze.mask.layer.backgroundColor = [[UIColor grayColor] CGColor];
_frieze.mask.backgroundColor = [UIColor grayColor];
但它不起作用。
有什么建议吗?
【问题讨论】:
标签: ios objective-c uiview uiimageview mask