Programmatically send to front/back elements created from interface builder

后端 未结 2 1997
甜味超标
甜味超标 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: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.

提交回复
热议问题