IOS uses modal views to implement bottom pop-up windows with black masks

Source: Internet
Author: User

This demo is only available for iOS8 and above systems.

This article uses Autolayout+storyboard to implement the pop-up window

First step, Storyboard create interface

1. Open Storyboard Drag a uiviewcontroller out and associated with class

2, drag out a uiview as a pop-up view of the container, the container to place the contents of the pop-up window, the container height according to the specific needs of the placement. The container is placed at the bottom

3, place a UIButton in the container view above the spacing of 0, and set the UIButton to black (for masking effect and click on the blank space to close the pop-up window)

4, constraints. The bottom container plays the left, right, bottom, and height constraints. UIButton play left, right, top, bottom constraints

Bottom container Constraint

UIButton constraints

5, constraints. Edit the bottom constraint of the bottom container to modify

Modify Container Bottom constraints

Modify Container Bottom constraints

Modify Container Bottom constraints

6, find the bottom of the container bottom constraints pull to the corresponding Uiviewcontroller

Cable

Second step, set mask and pop-up animation

1. Modify the transparency of the UIButton and set the background color of the Uiviewcontroller view to Transparent

Set transparency

2, the realization of the animation window, in the viewdidappear implementation, so that you can see the entire animation process

modifying constraints

3. Pop-up modal view

Modal view

Explanation of several attributes

explain the content to the blog Park do not Disturb is my gentle http://www.cnblogs.com/SenDylan/p/3953832.html

Providespresentationcontexttransitionstyle

Definespresentationcontext

Modalpresentationstyle

Part of the class read strange, not clear is not the reason for translation software.

4. Close the pop-up window

Close the pop-up window

Finally, demo GIF and demo.

Demo download

IOS uses modal views to implement bottom pop-up windows with black masks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.