I want to use exchangeSubviewAtIndex: withSubviewAtIndex: method.
but how can i get the indexes of those views? i already have their pointers, so I thought there might be a method like.
[parentView indexOfSubview:subview];
but I couldn't find that kind of thing in Xcode documents library.
please help me! thank you in advance.
If you need a quick way to get hold of a view inside a complicated view hierarchy, you're looking for viewWithTag() – give it the tag to find and a view to search from, and this method will search all subviews, and all sub-subviews, and so on, until it finds a view with the matching tag number.
The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.
This is how you get it:
[parentView.subviews indexOfObject:subview];
In Swift:
parentView.subviews.firstIndex(of: subview)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With