zoukankan      html  css  js  c++  java
  • 视图缩放、移动、旋转--ios

      
        UIView *view=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
        view.backgroundColor=[UIColor redColor];
        view.tag=10;
        [self.window addSubview:view];
        
        UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.frame=CGRectMake(200, 200, 50, 50);
        [button setTitle:@"改变" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(changeViewScale) forControlEvents:UIControlEventTouchUpInside];
        [self.window addSubview:button];
        
        UIButton *translateButton=[UIButton buttonWithType:UIButtonTypeSystem];
        translateButton.frame=CGRectMake(50,200, 50, 50);
        [translateButton setTitle:@"移动" forState:UIControlStateNormal];
        [translateButton addTarget:self action:@selector(changeViewTransalte) forControlEvents:UIControlEventTouchUpInside];
        [self.window addSubview:translateButton];
        
        UIButton *rotateButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        rotateButton.frame=CGRectMake(100, 200, 50, 50);
        [rotateButton setTitle:@"旋转" forState:UIControlStateNormal];
        [rotateButton addTarget:self action:@selector(changeViewRotate) forControlEvents:UIControlEventTouchUpInside];
        [self.window addSubview:rotateButton];
        
         [self.window makeKeyAndVisible];
    
    -(void) changeViewScale{
        UIView *view =[self.window viewWithTag:10];
        view.transform=CGAffineTransformScale(view.transform, 0.8, 0.8);
    }
    -(void) changeViewTransalte{
        UIView *view=[self.window viewWithTag:10];
        view.transform=CGAffineTransformTranslate(view.transform, 10,0);
    }
    -(void) changeViewRotate{
        UIView   *view=[self.window viewWithTag:10];
        view.transform=CGAffineTransformRotate(view.transform, 0.33);
    }
    
  • 相关阅读:
    flask_日期和时间
    使用SQLAlchemy对博客文章进行分页
    P2725 邮票 Stamps
    P2679 子串
    P3396 哈希冲突
    P1754 球迷购票问题
    P1504 积木城堡
    P1244 青蛙过河
    CSP-S 2019 考试分析
    2019.11.11 模拟赛 T2 乘积求和
  • 原文地址:https://www.cnblogs.com/clarence/p/3947738.html
Copyright © 2011-2022 走看看