UIView顺时针旋转、逆时针旋转

    因为项目需求,须要作点击向下剪头时,剪头逆时针旋转180度,再点击,顺时针旋转180度(恢复原位)动画

    由于个人基础不牢固,遇到这种知识点的问题就百度,可是网上找到的全是逆时针旋转,想改为顺时针,第一反应是把旋转角度前加“-”,惋惜无果。后来,试了几个角度值,终于实现的UIView的顺时针旋转code


逆时针旋转:orm

        //arrowLeft 是要旋转的控件
        //逆时针 旋转180度 
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:0.2]; //动画时长
        arrowLeft.transform = CGAffineTransformMakeRotation(180 *M_PI / 180.0);
        CGAffineTransform transform = arrowLeft.transform;
        //第二个值表示横向放大的倍数,第三个值表示纵向缩小的程度
        transform = CGAffineTransformScale(transform, 1,1);
        arrowLeft.transform = transform;
        [UIView commitAnimations];

顺时针旋转:it

        //顺时针 旋转180度
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:0.2]; //动画时长
        arrowLeft.transform = CGAffineTransformMakeRotation(0*M_PI/180);
        CGAffineTransform transform = arrowLeft.transform;
        transform = CGAffineTransformScale(transform, 1,1);
        arrowLeft.transform = transform;

    正常想法,一个控件经历一次顺时针旋转180度以后(也就是执行一遍这个方法),再执行一遍,应该是回归原位。可是不知道为何没有。多是跟设置坐标相似吧,它旋转的时候不是以如今的角度为基准进行旋转,而是必定固定好要旋转到的角度。我如今是这么理解的。项目忙,没时间细深究,等有空要好好研究一下iOS的各类动画效果以及参数。
io

相关文章
相关标签/搜索