button creation and setup

Source: Internet
Author: User

1 @interfaceViewcontroller ()2-(ibaction) Custombtnclick;3 4 @end5 6 @implementationViewcontroller7 8- (void) Viewdidload {9 [Super Viewdidload];Ten     //additional setup after loading the view, typically from a nib. One      AUIButton *btn =[UIButton Buttonwithtype:uibuttontypecustom]; -      -     //1. Setting the title the //Btn.titleLabel.text = @ "I am the button";//Please don't write like this . -     //In general, the contents of the button settings are setxxx -[BTN Settitle:@"I'm the button ."Forstate:uicontrolstatenormal]; -[BTN Settitle:@"Brother is highlighted"forstate:uicontrolstatehighlighted]; +      -     //2. Set the title color + //Btn.backgroundcolor = [Uicolor redcolor]; A [btn Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; at      -     //3. Settings icon -[Btn setimage:[uiimage imagenamed:@"Common_icon_check"] forstate:uicontrolstatenormal]; -      -     //4. Set the background image -[Btn setbackgroundimage:[uiimage imagenamed:@"common_button_big_blue_highlighted"] forstate:uicontrolstatenormal]; in      -     //5. Click on the Monitor button to     //Target: Who listens to the button +     //action: The method to be executed after the supervisor hears -     //Events : Type of event the     //rule: As long as it is inherited from the Uicontrol control, you can use Addtarget to add monitoring * [btn addtarget:self Action: @selector (Custombtnclick) forcontrolevents:uicontroleventtouchupinside]; $     Panax Notoginseng //Uiswitch sw = nil; - //[SW addtarget:<# (Nullable ID) #> action:<# (nonnull SEL) #> forcontrolevents:<# (uicontrolevents) # ;] the      + //Uisegmentedcontrol *sc = nil; A //[SC addtarget:<# (Nullable ID) #> action:<# (nonnull SEL) #> forcontrolevents:<# (uicontrolevents) #& gt;] the      + //Uitextfield *tf = nil; - //[TF addtarget:<# (nullable ID) #> action:<# (nonnull SEL) #> forcontrolevents:<# (uicontrolevents) # ;] $      $Btn.titleLabel.font = [Uifont systemfontofsize: -]; -Btn.frame = CGRectMake ( -, -, -, -); - [Self.view addsubview:btn]; the } - Wuyi-(ibaction) Custombtnclick { theNSLog (@"%s", __func__); - } Wu @end

button creation and setup

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.