I am working on a project. I have a UIView that has several subviews. I need to know how to mask only certain subviews to the parent view, or mask all but one particular view. Is there some way to add refinement checks to the maskToBounds property? Any direction or suggestion would be greatly appreciated.
2 Answers
What do you mean by masking?
If you want to hide particular view, you could create a standalone additional view and change its frame
to whichever view you want to hide. Then bring this standalone view to front of the view you want to hide, you could add it using insersubview :abovesubview
and variants of it. For more on it, see this.
This obviously requires that you are able to access them all using specific outlets, or through tags that you know of from subviews
array, to allow conditional masking.
If you would simply want to hide it instead of "masking" with some other content, your obvious choices are:
- set it's
hidden
property toYES
. - set it's
alpha
property to0.0
(or anything for fade out effect)

- 1
- 1

- 6,940
- 5
- 45
- 89
-
Masking a view, is a well-understood property. Access it at `.mask` or `.layer.mask` (which are slightly different). – Fattie May 02 '23 at 13:28
masking means autoresizing mask if it is yes means follow this UIView *customView = [[UIView alloc] initWithFrame:frame];
[customView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight];
follow this link may be useful to you UIView autoresizingMask - Interface Builder to Code - Programmatically create struts and springs - Swift or Objective-C?

- 1
- 1

- 161
- 10