How to Place custom view in IOS over another view

前端 未结 3 2020
情书的邮戳
情书的邮戳 2021-01-14 14:08

I want to achieve following custom view over UIViewController . What is the best way to acheive it rather then using addSubview I want to use some thing better.

3条回答
  •  臣服心动
    2021-01-14 14:29

    Use a Modal presentation with OverFullScreen mode. Set the background of the ViewController's view to transparent and place your custom view in the center of it.

    Easiest would be to use storyboards. Create a view controller with your custom view in the center. Otherwise, you need to call view.addSubView(..) to place your custom view on the center and create the constraints accordingly. To present this view controller you can create a segue or by code presentViewController(...). Don't forget to set the modalPresentationStyle to OverFullScreen.

    No library required.

提交回复
热议问题