Programmatically send to front/back elements created from interface builder

后端 未结 2 1996
甜味超标
甜味超标 2020-12-02 05:44

In interface builder, there are layout options to send to back or send to front any elements such as UIButton, UIImage, UILabel etc...

相关标签:
2条回答
  • 2020-12-02 06:24

    You could use:

    [self.view bringSubviewToFront:myButton];
    
    0 讨论(0)
  • 2020-12-02 06:26

    There are a number of methods of UIView that allow you to modify the view hierarchy.

    • bringSubviewToFront:
    • sendSubviewToBack:
    • insertSubview:atIndex:
    • insertSubview:aboveSubview:
    • insertSubview:belowSubview:
    • exchangeSubviewAtIndex:withSubviewAtIndex:

    Since your views are already inserted into your superview, you could easily call bringSubviewToFront: once for each view in whatever order you like.

    0 讨论(0)
提交回复
热议问题