UIButton
1 // 1. Set the left and right movement of the UIButton 2 The . Center property gets Cgpoint to modify X y 3 // 1. Set the UIButton to zoom out 4 The Bounds property gets cgrect and then sets the width by size.height setting the high wight
3. Or use frame to set the movement and size of the space
Code to create a UIButton
1 //1. Create a button2UIButton *btn =[[UIButton alloc] init];3 4 //2. Add a button5 [Self.view addsubview:btn];6 7 //3. Set the frame of the button8Btn.frame = CGRectMake ( -, -, -, -);9 Ten //4. Set the background picture for the default state and highlight status of the button One[Btn setbackgroundimage:[uiimage imagenamed:@"btn_01"] forstate:uicontrolstatenormal]; A[Btn setbackgroundimage:[uiimage imagenamed:@"btn_02"] forstate:uicontrolstatehighlighted]; - - //5. Set the color of text and text for the button's default state and highlight state, respectively the[BTN Settitle:@"dot me."Forstate:uicontrolstatenormal]; - [btn Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal]; - -[BTN Settitle:@"feel what I'm doing ."forstate:uicontrolstatehighlighted]; + [btn Settitlecolor:[uicolor Bluecolor] forstate:uicontrolstatehighlighted]; - + //6. Add a Click event to the button to monitor the button's click A [btn addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside]; at - - -- (void) Btnclick: (UIButton *) btn - { -NSLog (@"Btnclick"); in}
Simple animations
1 //There are two ways to create a simple animation2 //1. Tail type3[UIView Beginanimations:nil Context:nil];//Turn on animation4[UIView setanimationduration:1];//set animation execution Time5 //This writes the code that needs to execute the animation6[UIView commitanimations];//Submit Animation7 8 //2.Block Type9[UIView animatewithduration:0.5animations:^{Ten One //here, write an animated code that needs to be executed. A}];
IOS (ii) Basic controls UIButton, easy animations