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,