Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView subviews' order?

If i use a for loop;

for(UIView *subview in [myView subviews])

in which order, subviews are brought?

According to their added order or something else?

like image 808
erdemgc Avatar asked Jan 13 '23 11:01

erdemgc


1 Answers

As the documentation says, it reflects their visible order in the screen.

@property(nonatomic, readonly, copy) NSArray *subviews

Discussion

You can use this property to retrieve the subviews associated with your custom view hierarchies. The order of the subviews in the array reflects their visible order on the screen, with the view at index 0 being the back-most view.

For complex views declared in UIKit and other system frameworks, any subviews of the view are generally considered private and subject to change at any time. Therefore, you should not attempt to retrieve or modify subviews for these types of system-supplied views. If you do, your code may break during a future system update.

like image 89
Lucas Eduardo Avatar answered Jan 15 '23 00:01

Lucas Eduardo