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