Xcode: How To Create A PopUp View Controller That Appears In Another View Controller

后端 未结 7 581
-上瘾入骨i
-上瘾入骨i 2021-01-31 12:27

Basically what I am trying to figure out to do is, say I have one View Controller, called V1, that has a regular view inside it and a button. Now, when you tap that button, I wa

7条回答
  •  遇见更好的自我
    2021-01-31 12:51

    If you're using Storyboard, you can follow this step:

    1. Add a view controller (V2), setup the UI the way you want it

    *based on the image you attached

    • add an UIView - set background to black and opacity to 0.5
    • add an UIImageView - that will serve as your popup (Pls take note that the image and the view must not have the same level/hierarchy. Dont make the imageview the child of the view otherwise the opacity of the uiview will affect the uiImageView)
    1. Present V2 Modally

    2. Click the segue. In the Attributes inspector, Set Presentation as Over Full Screen. Remove animation if you like

    Storyboard

    1. Select V2. In the Attributes inspector, Set Presentation as Over Full Screen. Check Defines Context and Provides Context

    Storyboard

    1. Select the MainView of your V2 (Pls. Check image). Set backgroundColor to Clear Color

    Storyboard

提交回复
热议问题