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
#import <QuartzCore/QuartzCore.h>
needed to be added.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With