IOS (ii) Basic controls UIButton, easy animations

Source: Internet
Author: User

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

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.