Detailed Description: add borders to the view for iPhone development applications

Source: Internet
Author: User

This article describes how to add a border to a view for phone development applications. It mainly introduces an interesting case in the view to achieve the effect of adding a border to the view, let's take a look at the details. Through layer, you can add borders and rounded corners to the view. For example, write the following statement similar to the following:-(void) loadview {[[uiapplication sharedapplication] setstatusbarhidden: Yes withanimation: compatible]; uiimageview * contentview = [[myuiimageview alloc] initwithframe: [[uiscreen mainscreen] applicationframe]; [contentview setimage: [uiimage imagenamed: @ "1.jpg"]; [contentview setuserinteractionenabled: Yes]; self. view = [[uiview alloc] initwithframe: [uiscreen mainscreen] Applicationframe]; [self. view addsubview: contentview]; self. view. backgroundcolor = [uicolor blackcolor]; // Add the border contentview for the view. layer. maskstobounds = yes; contentview. layer. cornerradius = 20.0; contentview. layer. borderwidth = 10.0; contentview. layer. bordercolor = [[uicolor bluecolor] cgcolor]; [contentview release];} mainly refers to the four lines of code below the text comment. You can also use the code commented out above, but it is not concise to set the attributes later. To complete the code, you need to introduce the quartzcore library. In the header file, add: # import <quartzcore/quartzcore. h> to the frameworks section of the xcode project,


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.