In iOS, how do I create a button that is always on top of all other view controllers?

前端 未结 8 1868
悲哀的现实
悲哀的现实 2020-11-28 02:09

No matter if modals are presented or the user performs any type of segue.

Is there a way to keep the button \"always on top\" (not the top of the screen) throughout

8条回答
  •  借酒劲吻你
    2020-11-28 02:28

    Apple's intention in this case would be that your root view controller contain the button and whatever touch logic you want, and that it also embed as a child view controller whatever runs the rest of the app. You are not intended to talk to UIWindow directly, and are likely to hit a whole bunch of issues with things like autorotation across versions of iOS if you do.

    Old code may still manage to present modals on top using deprecated classes like UIAlertView. Apple has explicitly switched to approaches like UIAlertController where the thing that is covered explicitly owns the thing that is covering it in order to allow proper view controller containment. You should probably just make the same assumption and decline to use components that sit upon deprecated code.

提交回复
热议问题