Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Masking a UIView

I use the following code all the time in my view controller:

UIView *view = [[CustomView alloc] init];
UIView *mask = [[CustomMask alloc] init];
[view layer].mask =[mask layer];

and it masks the view as I want.

However, when it is not in a view controller I get the error:

'Request for member 'mask' in something not a structure or a union'

E.g. I want to apply the mask in the CustomView class itself. So I would have:

UIView *mask = [[CustomMask alloc] init];
[self layer].mask =[mask layer];

This produces the error. If I do it in my AppDelegate class with two images I get the same error again.

Can anyone explain how I can get the result I want.

Many thanks

like image 423
Theo Avatar asked Jul 24 '11 07:07

Theo


1 Answers

#import <QuartzCore/QuartzCore.h>

needed to be added.

like image 156
Theo Avatar answered Oct 23 '22 12:10

Theo