UI Basic View Control

Source: Internet
Author: User

Add a background picture to the parent view

Uiimageview *imgview=[[uiimageview alloc] initwithimage:[uiimage imagenamed:@ "Beijing"];

@ "" is the file name, so write the background picture must be dragged into the project to

Imgview.frame=self.view.bounds;

Automatically adapts to screen size

Imgview.autoresizingmask=uiviewautoresizingflexiblewidth;

Add a background picture to the parent view

[Self.view Insertsubview:imgview atindex:0];

Child view added to the specified location

Self.headview=[[uiimageview Alloc] Initwithframe:cgrectmake (45, 100, 30, 30)];

Add a picture with the file name [email protected]

[Self.headview setimage:[uiimage imagenamed:@ "[email protected]"];

[Self.view AddSubview:self.headView];

Add button

Self.buttonregister=[uibutton Buttonwithtype:uibuttontyperoundedrect];

Determine the position of the button in the parent view

Self.buttonregister.frame=cgrectmake (45, 300, 320, 50);

Set the name of the button

[Self.buttonregister settitle:@ "registration" forstate:uicontrolstatenormal];

The rounded corner of the button, the larger the value, the greater the rounded angle

self.buttonregister.layer.cornerradius=10;

Set the background color of the button

Self.buttonregister.backgroundcolor=[uicolor Whitecolor];

Sets the size and width of the font inside the button

_buttonregister.titlelabel.font=[uifont systemfontofsize:25 Weight:10];

Configure the color of the font inside the button

[Self.buttonregister settitlecolor:[uicolor colorwithred:0.176 green:0.627 blue:0.588 alpha:1] ForState: UIControlStateNormal];

Add a button view to the parent view

[Self.view AddSubview:self.buttonRegister];

Touch function

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *) event

{

Call the Hide keyboard function

[Self hidekeyboard];

}

/**

* Hide Keyboard functions

*/

-(void) Hidekeyboard

{

Determine if the response is first

if ([Self.textname1 isfirstresponder]| | [Self.textname2 Isfirstresponder])

{

Loss of First response

[Self.textname1 Resignfirstresponder];

[Self.textname2 Resignfirstresponder];

}

}

UI Basic View Control

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.