IOS floating window -- Analysis of popover implementation principle

Source: Internet
Author: User

Currently, all the popover menus, loadingview, and so on are engaged in views, which can be solved. However, the display is actually quite troublesome. You have to ensure full screen, removefromsuperview at addsubview, and removefromsuperview at the disappearance. You also need to ensure that the view is at the top level and the code is not highly reusable.


In fact, the iPhone supports multi-window display and hierarchical display, that is, the windowlevel of the window is set. Similar properties on Mac can be used to display windows with different effects.


Then we can completely alloc a window and make it a keywindow, so all touch events will be captured by it. And it is a view. You can set the backgroundcolor in addsubview. The problem is simple. You should be able to understand the popoverwindow principle on the iPad.


That is to generate a window with the fullscreen windowlevel ui‑walertlevel, And the backgroundcolor is clearcolor. Then, add the view of the Controller to be displayed to the subview, and draw a border around the view in drawrect, draw an arrow on the pop-up point and display it in an animation. Then, click the blank area of the window to make the animation disappear.

Uialertview is simpler. Although it inherits from uiview, its implementation should be no different from that of uiwindow. In fact, it should also be a window, set different content heights and adjust the content size according to different subviews.

Code implementation address: http://www.cocoachina.com/bbs/read.php? Tid-30657.html

Related Article

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.