Prashanth Rajagopalan Prashanth Rajagopalan - 4 months ago 43
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.


Objective-C (KVC)

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


mainView.subviews.forEach { $0.isHidden = true }