5

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

1
  • Perfect. Thank you. Exactly what I needed. You have answered my question in your question, that is: How to mask a UIView with another UIView (without using an image)? Commented Dec 20, 2012 at 15:38

1 Answer 1

6
#import <QuartzCore/QuartzCore.h> 

needed to be added.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.