I was wondering how to make a popup window similar to this example:

The origin window is full of buttons that when is selected will then pull up the image I desire to use.
I would simply create a reusable UIView
component and everything you need as a subview, such as a UIImageView
for your image, a UILabel
or a UIButton
in the top right. Here is the process to show it:
- Create a
UIView
that takes up the full screen, make it black, and maybe 0.5 alpha. - Create another
UIView
which is your primary pop-up view, make it slightly smaller than the previous view, but make sure both of these views are subviews of the parent subview. - Add the desired elements on to the pop-up view as subviews, I would even suggest creating a
UIView
subclass if you plan to use this a lot. - To present the pop-up, make sure both views are set to
hidden = true
when created and so that when a button is selected, you can set them tohidden = false
- If you would like them to be animated, simply start them off with
alpha = 0.0
and use something like UIView'sanimateWithDuration
and set the pop-up view toalpha = 1.0
There is a lot of little details you can change to cater to your needs, but this is the basic structure on how to accomplish your goal.
Check out UIView animation methods here.
来源:https://stackoverflow.com/questions/27663262/how-to-make-a-popup-window-with-an-image-swift