zoukankan      html  css  js  c++  java
  • ios-center 和 bounds用法

    //
    //  ViewController.m
    //  MovePicture
    //
    //  Created by YaguangZhu on 15/7/28.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    - (IBAction)move:(UIButton *)sender;
    
    - (IBAction)scale:(UIButton *)sender;
    
    
    
    @property (weak, nonatomic) IBOutlet UIButton *btnIcon;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    - (IBAction)move:(UIButton *)sender {
        
        CGPoint centerPoint =  self.btnIcon.center;
        switch (sender.tag) {
            case 10:
                NSLog(@"up");
                centerPoint.y -=10;
                break;
            case 20:
                NSLog(@"right");
                centerPoint.x +=10;
                break;
            case 30:
                NSLog(@"down");
                centerPoint.y +=10;
                break;
            case 40:
                NSLog(@"left");
                centerPoint.x -=10;
                break;
            default:
                break;
        
        }
        
        self.btnIcon.center = centerPoint;
    
    }
    
    - (IBAction)scale:(UIButton *)sender {
        
        CGRect originBounds = self.btnIcon.bounds;
        if (sender.tag == 100) {
             NSLog(@"big");
            originBounds.size.height +=10;
            originBounds.size.width +=10;
            
            self.btnIcon.bounds = originBounds;
        }else
        {    NSLog(@"small");
            originBounds.size.height -=10;
            originBounds.size.width -=10;
            
            self.btnIcon.bounds = originBounds;
    
        }
        
        self.btnIcon.bounds = originBounds;
    }
    
    
    @end
  • 相关阅读:
    6.4 记录
    Python向mysql数据库插入数据
    6.2号课下作业测试标准的好坏
    模糊查询
    日常开发问题解决
    日常开发问题解决
    tomcat容器启动失败疑难问题解决方案
    5.14 记录
    5.13 记录
    关于HTTP,TCP,IP的一些基础知识
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4685226.html
Copyright © 2011-2022 走看看