2

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.

HenryGale
  • 681
  • 6
  • 25
  • No, you can't control the mask like that. Tell us what you want to achieve (with screenshots). – Wain Aug 18 '13 at 18:19

2 Answers2

1

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 to YES.
  • set it's alpha property to 0.0 (or anything for fade out effect)
Community
  • 1
  • 1
Nirav Bhatt
  • 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
-2

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?

Community
  • 1
  • 1