Clipstobounds attributes and extensions in iOS learning UIView

Source: Internet
Author: User

Add a child view dynamically in a view, and add a uibutton in the child view, after the run found that although the interface can see the Buton, but click on the button when the button is not responding, tangled for a long time did not find what the problem, the code is as follows:

Later on the Internet to find some information, found that UIView has a clipstobounds attribute, so view.clipstobounds set to Yes, found that the interface button is not visible, continue to see some clipstobounds information, The frame of the button is beyond the scope of the view frame (that is, the button's coordinates are outside the frame of the view), the default value of Clipstobounds is no, that is, it can still be displayed after the range is out, but out of range this part cannot respond to touch events. After setting the clipstobounds to Yes, the contents of this part of the range will no longer be displayed. When you set a frame to view in the code above, the button responds normally.

Here is an illustration of clipstobounds (borrowed from someone else's diagram), where the View2 is added to the View1, and the view2 is partially beyond the view1 frame:

Clipstobounds = no when (default value)

Clipstobounds = yes

Clipstobounds attributes and extensions in iOS learning UIView

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.