Masking a UIView

核能气质少年 提交于 2019-12-04 01:28:18

问题


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:


#import <QuartzCore/QuartzCore.h>

needed to be added.



来源:https://stackoverflow.com/questions/6805444/masking-a-uiview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!