Ui-label button

Source: Internet
Author: User

#import "AppDelegate.h"@interfaceappdelegate ()@end@implementationappdelegate{//Global Variablesuilabel*Lablel;}-(void) dealloc{Self.window=Nil; [Super Dealloc];}-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch.Self.window=[[UIWindow Alloc]initwithframe:[uiscreen mainscreen].bounds]; Self.window.backgroundColor=[Uicolor Whitecolor];        [Self.window makekeyandvisible]; //Create LablelLablel=[[uilabel Alloc]initwithframe:cgrectmake ( -, -,280, -)]; Lablel.backgroundcolor=[Uicolor Browncolor]; //Set TextLablel.text =@"Hello, Helle World Hello, Helle World Hello, Helle World"; //Set Text colorLablel.textcolor =[Uicolor Whitecolor]; //set the number of lines of textLablel.numberoflines =0; //Text Alignment//lablel.textalignment = Nstextalignmentleft; //lablel.textalignment = nstextalignmentright;Lablel.textalignment =Nstextalignmentcenter; //get the font of the systemNSLog (@"%@", [Uifont familynames]); //set font and font sizeLablel.font = [Uifont fontwithname:@"Tamil Sangam MN"Size the]; //BoldLablel.font = [Uifont boldsystemfontofsize: -]; //Italic Body//Lablel.font = [Uifont italicsystemfontofsize:20]; //Shadow color//Lablel.shadowcolor = [Uicolor Redcolor]; //Shadow offset//lablel.shadowoffset = cgsizemake (0,-10); //To omit ...//Lablel.linebreakmode =nslinebreakbytruncatinghead;//omission of the header//Lablel.linebreakmode =nslinebreakbytruncatingmiddle;//Middle omitted//Lablel.linebreakmode =nslinebreakbytruncatingtail;//trailing ellipsis//Highlight Statelablel.highlighted =YES; //Highlight Font ColorLablel.highlightedtextcolor =[Uicolor Greencolor]; //Lablel Self-adapting//automatically get text content hosting range//[Lablel SizeToFit];[Self.window Addsubview:lablel];        [Lablel release]; //to create a method for a class//Main response Events//custom UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];UIButton *btn =[UIButton Buttonwithtype:uibuttontyperoundedrect]; Btn.backgroundcolor=[Uicolor Browncolor]; Btn.frame= CGRectMake ( -, -, $, $); //button Status-set text and color//Normal State[BTN Settitle:@"dot me!"Forstate:uicontrolstatenormal];    [btn Settitlecolor:[uicolor Whitecolor] forstate:uicontrolstatenormal]; //Highlight State[BTN Settitle:@"don't order me."forstate:uicontrolstatehighlighted];    [btn Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatehighlighted]; //Disabled//[btn settitle:@ "Disable" forstate:uicontrolstatedisabled]; //btn.enabled = YES; //Set the button shadow color and offset//[btn Settitleshadowcolor:[uicolor Greencolor] forstate:uicontrolstatenormal]; //Btn.titleshadowoffset = Cgsizemake (5, 5); //this insertion is not recommended//[btn setimage:[uiimage imagenamed:@ "button_foot1"] forstate:uicontrolstatenormal]; //pull the picture up to the size of the BTN[Btn setbackgroundimage:[uiimage imagenamed:@"button_foot1"] Forstate:uicontrolstatenormal]; //Create a UIImage objectUiimage*image = [UIImage imagenamed:@"checked"]; //Checked Status[btn setbackgroundimage:image forstate:uicontrolstateselected]; Btn.selected=NO; Btn.showstouchwhenhighlighted=YES; //Btn.imageview//Btn.titlelabelLablel.text=@"0"; //Add Event[btn addtarget:self Action: @selector (OnClick:) forcontrolevents:uicontroleventtouchupinside];//[btn addtarget:self Action: @selector (OnClick://) Forcontrolevents:uicontroleventtouchdown];[Self.window addsubview:btn]; returnYES;}-(void) OnClick: (uibutton*) sender{Nsinteger n=[lablel.text intvalue]+1; Lablel.text= [NSString stringWithFormat:@"%d", n]; NSLog (@"%@", Lablel.text); //if (sender.selected = = NO) {//sender.selected = YES; //    }    //Else//    {    //sender.selected = NO; //    }    //sender.enabled = NO; //switchable click Iconsender.selected =!sender.selected;}- (void) Applicationwillresignactive: (UIApplication *) Application {//Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US    Er quits the application and it begins the transition to the background state. //Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.}- (void) Applicationdidenterbackground: (UIApplication *) Application {//Use the method to release the shared resources, save user data, invalidate timers, and store enough application state in    Formation to the restore your application to the it is terminated later. //If Your application supports background execution, this method is called instead of Applicationwillterminate:when th E user quits.}- (void) Applicationwillenterforeground: (UIApplication *) Application {//Called as part of the transition from the background to the inactive state; Here you can undo many of the changes mad E on entering the background.}- (void) Applicationdidbecomeactive: (UIApplication *) Application {//Restart Any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.}- (void) Applicationwillterminate: (UIApplication *) Application {//Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.}@end

Ui-label button

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.