iOS UI section two basic controls

Source: Internet
Author: User

Uilable UIBUtton Uitextfield

-(BOOL) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions {

Override point for customization after application launch.

self. Window = [[UIWindow alloc]initwithframe: [[UIScreen mainscreen]bounds]];

[Self. Window setbackgroundcolor: [Uicolor Graycolor]];

[Self. Window makekeyandvisible];

[self createlabel];

[self CreateField];

[self Createbutton];

return YES;

}

-(void) Createlabel

{

UILabel *alabel = [[UILabel alloc]initwithframe:cgrectmake ( [n], []];

[Alabel setbackgroundcolor: [Uicolor Whitecolor]];

[Self. window Addsubview:alabel];

[Label settext:@ "mother Fuck"];

Alabel. text = @ "Fuck off,bitch afasfsfasfas!131311231";

[Label Settextcolor:[uicolor Blackcolor];

Alabel.textcolor = [Uicolor redcolor];

Center Text

[Alabel settextalignment: Nstextalignmentcenter];

// set font

//Create an object to accept

Uifont *newfont = [Uifont systemfontofsize:25];

Uifont *newfont1 = [Uifont boldsystemfontofsize:25];

Uifont *newfont2 = [Uifont italicsystemfontofsize:];

[Alabel Setfont:newfont2];

//Line Note height , as long as the height is enough, set to 0

Alabel. numberoflines = 0;

[Alabel setshadowcolor: [Uicolor Bluecolor]];

[Alabel setshadowoffset: Cgsizemake(1, 2)];

set tag value to take content

[Alabel settag:100];

[Alabel release];

}

Input box

-(void) CreateField

{

local variables, Self.afiedl relative global variables

self. Afield = [[Uitextfield alloc]initwithframe: CGRectMake( +, +, +)];

[_afield setbackgroundcolor: [Uicolor Whitecolor]];

[Self. Window addsubview: _afield];

[Afield settext:@ " enter password"];

[_afield settextalignment: Nstextalignmentleft];

[Afield setalpha:1];

[_afield settextcolor: [Uicolor Graycolor]];

set prompt placeholders

[_afield setplaceholder:@ " Enter password "];

//Enter character and change to Asterisk

_afield. Securetextentry = YES;

[_afield release];

}

-(void) Createbutton

{

UIButton *button = [UIButton buttonwithtype: Uibuttontypecustom];

// location

[Button setframe:cgrectmake ( +,,,)];

[Button SetBackgroundColor: [Uicolor Purplecolor];

[Self. window Addsubview:button];

[Button Settitle:@ " dot " forstate: UIControlStateNormal ];

[Button Settitle:@ " checked " forstate: uicontrolstatehighlighted ];

[Button Settitlecolor: [Uicolor yellowcolor] forstate: uicontrolstatehighlighted];

//Add a click event

UIControlEventTouchUpInside Click to lift up

[Button AddTarget:self Action:@selector(buttonaction:) forcontrolevents: UIControlEventTouchUpInside];

}

-(void) Buttonaction: (ID) sender

{

NSLog (@ "%s", __func__);

//Let the input box lose the first responder

[self. Afield Resignfirstresponder];

//tag Value The parent view finds himself and all child views with a tag value of 100

UILabel *aview = (UILabel *) [Self. Window viewwithtag: +];

I 'm going to give filed a label.

[Aview setText: Self. Afield. text];

}

iOS UI section two basic controls

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.