Buttons in iOS (UIButton)

Source: Internet
Author: User

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {Self.window=[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; //Override point for customization after application launch.            /** UIButton: is a control in iOS that responds to user click events, and is a subclass of Uicontrol UIButton use steps: 1. Create a Control object 2. Configure Properties 3. Add to Parent View*/    //1. Creating a controlUIButton *button =[UIButton Buttonwithtype:uibuttontypecustom]; //Uibuttonwtypesystem do not uibuttontypesystem when setting a picture for button//2. Configuration Properties//Button.backgroundcolor = [Uicolor Greencolor]; //(1) Set frameButton.frame = CGRectMake (Ten, -, -, +); //[button settitle:@ "registration" forstate:uicontrolstatenormal]; //[button Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; //set up a picture[Button Setimage:[uiimage imagenamed:@"Login_btn_normal"] Forstate:uicontrolstatenormal]; [Button setimage:[uiimage imagenamed:@"login_btn_press"] forstate:uicontrolstatehighlighted]; //3. Add Parent View[Self.window Addsubview:button]; //4. Add Response Events//Self represents the object of the response method//target Specifies the event response object//Action: Specifies the method to be called by the response object to handle the button click event//controlevents: Timing of event triggering//The Handleaction method can have parameters and only one parameter, because the parameter is the object that invokes the AddTarget:action:forControlEvent: Method (that is, the button that implements the method)[button addtarget:self action: @selector (thisbuttonshow:) forcontrolevents:uicontroleventtouchupinside]; /** * Control Summary Each control is used to implement a specific function UILabel: Used to display text Uitextfield: The compilation UIButton used for text: To respond to user interaction events, to respond to user click events, and to display     Text and pictures. */Self.window.backgroundColor=[Uicolor Whitecolor];    [Self.window makekeyandvisible]; returnYES;}

Buttons in iOS (UIButton)

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.