IOS UI Basics-1.1 button operation and deformation

Source: Internet
Author: User

Button State 1.normal: The default state of the enumeration constant corresponding to the UIControlStateNormal: 2. Highlighted (when highlighted) button is pressed (not released) the corresponding enumeration constant: uicontrolstatehighlighted 3.disabled (Invalid state, unavailable) if the Enable property is no, is in the disabled state, the representative button can not be clicked on the corresponding enumeration constant: uicontrolstatedisabled up and down operation, ideas: 1. Add a tag value of 2 for each operation. According to the tag value, the Click is the button
/** Frame property, typically used to instantiate the control, specify the initial position if you need to change the position of the control, you can use the Center property if you need to change the size of the control, you can use the Bounds property*/-(Ibaction) Move: (UIButton *) button{//tips, you can also change the location by center, you can practice after classCgpoint Center =Self.iconButton.center; //2. According to the type of the button tag, determine the direction of movement, and then modify the structure of the Members//magic number Magical numbers    Switch(Button.tag) { CaseKmovingdirtop://onCENTER.Y-=10.0f;  Break;  CaseKmovingdirbottom://underCenter.y + =10.0f;  Break;  CaseKmovingdirleft://leftCenter.x-=10.0f;  Break;  CaseKmovingdirright://RightCenter.x + =10.0f;  Break; }        //3. Re-assign a value to the structure property of the objectSelf.iconButton.center =Center; NSLog (@"%@", Nsstringfromcgrect (Self.iconButton.frame));}
Transform using 1. Position movement
// Move Up -(ibaction) Top: (UIButton *) Sender {    //  1.transform is a state relative to the initial state, But in fact the value of Self.head.frame.origin has been changed //    self.head.transform = Cgaffinetransformmaketranslation (0, self.head.transform.ty-20);        // 2. Use the original transform to generate a new transform    0,-);}

2. Size change

// Zoom -(ibaction) Narrow: (UIButton *) Sender {    //  Zoom out 20%     0.80.8 ); }

3. Rotate

/**/-(ibaction) Rotate: (UIButton *) button{    // in OC Development, For angular unification, use the Radian value, counterclockwise is negative, clockwise is positive     //  180°= m_pi    cgfloat angle = (button.tag)?-M_pi_4: M_pi_4;        [UIView Beginanimations:nil Context:nil];     = cgaffinetransformrotate (self.iconButton.transform, angle);    [UIView commitanimations];}

IOS UI Basics-1.1 button operation and deformation

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.