码迷,mamicode.com
首页 > 其他好文 > 详细

360旋转动画

时间:2014-10-18 19:40:14      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:io   for   sp   on   ad   ef   bs   size   as   

-(void)rote360Image{

    CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"transform" ];

    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];

    //圍繞z軸旋轉,垂直螢幕

    animation.toValue =[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0, 0, 1.0)];

    animation.duration = 3;

    //旋轉效果累計,先轉180度,接著再旋轉180度,從而實現360度旋轉

    animation.cumulative = YES;

    animation.repeatCount = 2;

    

    //在圖片邊緣新增一個像素的透明區域,去圖片鋸齒

    CGRect imageRrect = CGRectMake(0, 0,self.splashImageView.frame.size.width, self.splashImageView.frame.size.height);

    UIGraphicsBeginImageContext(imageRrect.size);

    [self.splashImageView.image drawInRect:CGRectMake(1,1,self.splashImageView.frame.size.width-2,self.splashImageView.frame.size.height-2)];

    self.splashImageView.image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

    [self.splashImageView.layer addAnimation:animation forKey:nil];

}

360旋转动画

标签:io   for   sp   on   ad   ef   bs   size   as   

原文地址:http://www.cnblogs.com/wangzhendong/p/4033482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!