iOS zoom, rotate UIButton

Source: Internet
Author: User

When you practice scaling the UIButton control, the click Control X, Y, or both increases or minus a certain number of pixels, after the search is XCODE5 turned on auto Layout.

Zoomed-out Code

-(Ibaction) Btnscale: (UIButton *) Sender {    //animation start, set execution time    [UIView beginanimations:nil context:nil];    [UIView Setanimationduration:1];    int tag = [sender tag];    float Scale = Tag = = 8? 1.2:0.8;    Cgaffinetransform _transform = _btn.transform;    _btn.transform = Cgaffinetransformscale (_btn.transform, scale, scale);    _transform = _btn.transform;    Commit animation    [UIView commitanimations];}

Left and right rotation code

-(Ibaction) Btnrotate: (UIButton *) sender {    [UIView beginanimations:nil context:nil];    [UIView Setanimationduration:1];    int tag = [sender tag];    int rotate = Tag = = 7? 1:-1;    _btn.transform = Cgaffinetransformrotate (_btn.transform, m_pi_4*rotate);    int rotate = tag==7? 1:-1;    _btn.transform = Cgaffinetransformrotate (_btn.transform, m_pi_4*rotate);    [UIView commitanimations];}

Actions to restore controls

-(Ibaction) Btnreset: (UIButton *) sender {    [UIView beginanimations:nil context:nil];    [UIView Setanimationduration:1];    Sender.transform = cgaffinetransformidentity;    [UIView commitanimations];}

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.