Small UI case-removable, scalable

Source: Internet
Author: User

////VIEWCONTROLLER.M//02--anniu button-hook up git////Created by Longma on 15/8/29.//Copyright (c) movedDistance15 year itcast. All rights reserved.//#import"ViewController.h"#defineMoveddistance 20typedefenum{Topbutton=Ten, Bottombutton, LeftButton, Rightbutton, Zoomout, Zoomin}kbutton; @interface Viewcontroller () @property Iboutlet UIButton*Buttonofimage;-(Ibaction) Move: (UIButton *) button; @end @implementation Viewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.}- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.        }-(ibaction) Zoom: (uibutton*) button{cgrect bounds=Self.buttonOfImage.bounds; if(Button.tag = =zoomout) {Bounds.size.height+=moveddistance; Bounds.size.width+=moveddistance; }Else{bounds.size.height-=moveddistance; Bounds.size.width-=moveddistance; } self.buttonOfImage.bounds=bounds; /*CGRect orgframe = self.buttonOfImage.frame;        if (Button.tag = = zoomout) {orgframe.size.height + = moveddistance;    Orgframe.size.width + = moveddistance;        }else {orgframe.size.height-= moveddistance;    Orgframe.size.width-= moveddistance;     } self.buttonOfImage.frame = Orgframe; */    }-(Ibaction) Move: (UIButton *) button{//1. Get the centerCgpoint Center =Self.buttonOfImage.center; //2. Judging the button and modifying the coordinates    Switch(Button.tag) { CaseTopbutton:center.y-=moveddistance;  Break;  CaseBottombutton:center.y+=moveddistance;  Break;  Caseleftbutton:center.x-=moveddistance;  Break;  Caserightbutton:center.x+=moveddistance;  Break; default:             Break; }    //3. Re-assign ValueSelf.buttonOfImage.center =Center; /*CGRect frameofimg = self.buttonofimage.frame;//no * switch (button.tag) {case Topbutton:f            RAMEOFIMG.ORIGIN.Y-= moveddistance;        Break            Case BOTTOMBUTTON:FRAMEOFIMG.ORIGIN.Y + = moveddistance;        Break            Case leftbutton:frameofimg.origin.x-= moveddistance;        Break            Case rightbutton:frameofimg.origin.x + = moveddistance;        Break    Default:break;     } self.buttonOfImage.frame = frameofimg; */} @end

Small UI case-removable, scalable

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.