Prashanth Rajagopalan Prashanth Rajagopalan - 1 year ago 138
Objective-C Question

Hide UIView subviews

I have UIView which have n number of subviews. Let say n as 600 subviews. I know there is a way to hide all the subviews by the following code

for (UIView *subView in mainView.subviews) {
subView.hidden = YES;

But is there are any other proper way or API's to hide all the subviews.Thanks in advance.

Answer Source

Objective-C (KVC)

[mainView.subviews setValue:@YES forKeyPath:@"hidden"];


mainView.subviews.forEach { $0.isHidden = true }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download