How can I get the index of sub UIView in the parent view?

后端 未结 4 1699
闹比i
闹比i 2021-01-05 02:11

I want to use exchangeSubviewAtIndex: withSubviewAtIndex: method.

but how can i get the indexes of those views? i already have their pointers, so I

4条回答
  •  悲哀的现实
    2021-01-05 03:08

    This is how you get it:

    [parentView.subviews indexOfObject:subview];

    In Swift:

    parentView.subviews.firstIndex(of: subview)
    

提交回复
热议问题