美文网首页
图片绕中心点旋转

图片绕中心点旋转

作者: lifeLL | 来源:发表于2019-12-27 11:08 被阅读0次
  • (UIImageView *)rotate360DegreeWithImageView:(UIImageView *)imageView{
    CABasicAnimation *animation = [ CABasicAnimation
    animationWithKeyPath: @"transform" ];
    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];

    //围绕Z轴旋转,垂直与屏幕
    animation.toValue = [ NSValue valueWithCATransform3D:

                       CATransform3DMakeRotation(M_PI, 0.0, 0.0, 1.0) ];
    

    animation.duration = 0.5;
    //旋转效果累计,先转180度,接着再旋转180度,从而实现360旋转
    animation.cumulative = YES;
    animation.repeatCount = 1000;

    //在图片边缘添加一个像素的透明区域,去图片锯齿
    CGRect imageRrect = CGRectMake(0, 0,imageView.frame.size.width, imageView.frame.size.height);
    UIGraphicsBeginImageContext(imageRrect.size);
    [imageView.image drawInRect:CGRectMake(1,1,imageView.frame.size.width-2,imageView.frame.size.height-2)];
    imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    [imageView.layer addAnimation:animation forKey:nil];
    return imageView;
    }

animation.repeatCount = 1000;
这个你要想一直旋转,设置一个无穷大就得了

停止的话直接这样就停止了
[self.view.layer removeAllAnimates];

from http://blog.sina.com.cn/s/blog_9075354e0101t72s.html

相关文章

  • 图片绕中心点旋转

    (UIImageView *)rotate360DegreeWithImageView:(UIImageView ...

  • iOS 视图围绕指定点旋转

    今天在做一个旋转动画时,需要这个view像时钟的针那样绕中心点旋转。默认一个视图旋转时是绕自身的中心点进行旋转的。...

  • NSView绕中心点旋转

    我们可以NSView添加一个扩展,实现一个开始动画的过程。我们可以使用CABasicAnimation来实现,通常...

  • 【Android】android.graphics.Camera

    Camera绕中心旋转的方法 在使用Camera进行3D旋转的时候,发现转动的中心点是屏幕左上角,并且没有相关方法...

  • 2018-11-28

    变形 元素旋转 变形中心点 背面可见 图片翻面 animation动画 人物走路动画 多帧动画

  • position/anchorPoint

    anchorPointd是图片旋转点 anchorPointd 范围是 0 - 1 view的中心点、左下角和右上...

  • 2019-06-04

    css基础知识 变形: 元素旋转 变形中心点: 背面可见 图片翻转: animation动画: 定义动画名称及形式...

  • iOS(手势:拖拽,旋转,缩放)-室内地图-手势篇

    缩放手势 旋转手势 设置map旋转缩放中心点,当手势操作时,设置map中心的为两指中心点 多手势支持(同时支持旋转...

  • CSS动画二

    图片文字遮罩 变形 效果如下: 当鼠标移入时就会发生变形 元素旋转 变形中心点 animation动画 anima...

  • 计算三维图形旋转后坐标

    三维图形几何变换是二维图形几何变换的扩展。在二维空间中绕一个中心点旋转,实际上就是绕原点旋转再平移,那么在三维空间...

网友评论

      本文标题:图片绕中心点旋转

      本文链接:https://www.haomeiwen.com/subject/gaoroctx.html