360旋转动画

-(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];

}

posted @ 2014-10-18 18:29  王振东  阅读(114)  评论(0编辑  收藏  举报