-(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)