zoukankan      html  css  js  c++  java
  • UIView 实战习题

    UIView 实战习题

     一 按钮操作

    1 题目描述

    2 代码

    //
    //  WHBLAPViewController.m
    //  03-按钮操作
    //
    //  Created by whblap on 14-5-26.
    //  Copyright (c) 2014年 whblap. All rights reserved.
    //
    
    #import "WHBLAPViewController.h"
    // 设置位移像素点
    #define displacement 10
    // 设置旋转角度大小
    // C++里面预编译处理 是这样写的  const int displacement  = 10;
    @interface WHBLAPViewController ()
    
    @end
    
    @implementation WHBLAPViewController
    
    #pragma mark - 控制按钮上下左右走动 
    - (IBAction)butten:(id)sender {
        // OC语法规定:不允许直接修改 某个对象中结构体属性的成员
        
        // 设置动画开始
        [UIView beginAnimations:nil context:nil];
        // 设置动画时间
        [UIView setAnimationDuration:0.5];
        CGRect tempFrame = _btn.frame; // 将_btn位置属性赋值给临时的tempFrame
        
        int tag = [sender tag];
    //    CGFloat displacement = 10;
        switch (tag) {
            case 1:
                tempFrame.origin.y -= displacement;
                break;
            case 2:
                tempFrame.origin.y += displacement;
                break;
            case 3:
                tempFrame.origin.x -= displacement;
                break;
            case 4:
                tempFrame.origin.x += displacement;
                break;
        }
        _btn.frame = tempFrame;
        // 结束动画
        [UIView commitAnimations];
    
    }
    - (IBAction)rotateAndZoom:(id)sender {
        switch ([sender tag]) {
            case 5:
                _btn.transform = CGAffineTransformRotate(_btn.transform, -M_PI_4); //在原来比例——btn.transform下再放大
                break;
            case 6:
                _btn.transform = CGAffineTransformRotate(_btn.transform, +M_PI_4);
                break;
            case 7:
                _btn.transform = CGAffineTransformScale(_btn.transform, 1.2, 1.2);
                break;
            case 8:
                _btn.transform = CGAffineTransformScale(_btn.transform, 0.8, 0.8);
                break;
        }
    }
    @end
    

     

    今天过得开心又充实,么么哒
  • 相关阅读:
    SSM中 web.xml配置文件
    实现网站的登陆,注册,查看商品详细信息,加入购物车,注销登陆等简单功能。
    操作步骤
    mysql 查询 练习题及答案
    水仙花数!
    Spark SQL(4)-Unresolved Plan到Analyzed Plan
    Spark SQL(3) Parser到Unresolved LogicPlan
    Spark SQL(2)-InternalRow和TreeNode
    Spark SQL(1)-简述
    logstash output到kafka记录与总结( No entry found for connection 2)
  • 原文地址:https://www.cnblogs.com/whblovelap/p/3825659.html
Copyright © 2011-2022 走看看