• 020606-05-transform


    //
    //  ViewController.m
    //  05-transform
    #import "ViewController.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) UIView *tempView;
    
    //@property (nonatomic, assign) CGFloat angle;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
        [tempView addSubview:[[UISwitch alloc] init]];
        tempView.backgroundColor = [UIColor redColor];
        tempView.transform = CGAffineTransformMakeRotation(M_PI_4);
        [self.view addSubview:tempView];
        self.tempView = tempView;
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        // 清空transform,以前的平移、缩放、旋转都会消失
        [UIView animateWithDuration:2.0 animations:^{
            self.tempView.transform = CGAffineTransformIdentity;
            
        }];
        
    //    self.angle += M_PI_4;
        
    //    [UIView animateWithDuration:1.0 animations:^{
    ////        self.tempView.transform = CGAffineTransformScale(self.tempView.transform, 0.8, 0.8);
    //        self.tempView.transform = CGAffineTransformRotate(self.tempView.transform, M_PI_4);
    //    }];
        
        
        // transform:形变属性,能完成的功能:平移、缩放、旋转
    //    [UIView animateWithDuration:2.0 animations:^{
    //        // 缩放
    //        self.tempView.transform = CGAffineTransformMakeScale(0.5, 0.5);
    //        // 平移
    //        self.tempView.transform = CGAffineTransformMakeTranslation(-100, 100);
            // 旋转
    //        self.tempView.transform = CGAffineTransformMakeRotation(-M_PI_4);
            
    //        CGAffineTransform translation = CGAffineTransformMakeTranslation(-100, 100);
    //        CGAffineTransform scaleTranslation = CGAffineTransformScale(translation, 0.5, 0.5);
    //        CGAffineTransform rotateScaleTranslation = CGAffineTransformRotate(scaleTranslation, M_PI_2);
    //        self.tempView.transform = rotateScaleTranslation;
    //    }];
    }
    
    @end
    本人无商业用途,仅仅是学习做个笔记,特别鸣谢小马哥,学习了IOS,另日语学习内容有需要文本和音频请关注公众号:riyuxuexishuji
  • 相关阅读:
    linux中mysql表名默认区分大小写导致表找不到的问题
    将hive的hql执行结果保存到变量中
    excel导出功能优化
    shell中执行hive命令错误:delimited by end-of-file (wanted `EOF')
    javascript中全局变量的定义
    datagrid中reoload提交时如何批量提交表单中的查询条件
    Linux下查看文件和文件夹大小
    Linux 时间修改--date -s命令
    Unicode字符集,各个语言的区间
    js实现可兼容IE、FF、Chrome、Opera及Safari的音乐播放器
  • 原文地址:https://www.cnblogs.com/laugh/p/6508903.html
Copyright © 2020-2023  润新知