`
修博龙泉
  • 浏览: 313054 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

动画-图片旋转

阅读更多
旋转:
iv = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)];
    [iv setImage:[UIImage imageNamed:@"dial_panel"]];
    //CALayer *rotate_layer = iv.layer;
    [self.view addSubview:iv];
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
    animation.delegate = self;
    animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI , 0, 0, 1.0)];
    animation.duration = 1;
    animation.cumulative = YES;
    animation.repeatCount = INT_MAX;
    animation.speed = 10;
    [iv.layer addAnimation:animation forKey:@"animation"];

暂定:
    CFTimeInterval pausedTime = [iv.layer convertTime:CACurrentMediaTime() fromLayer:nil];
    iv.layer.speed = 0.0;
    iv.layer.timeOffset = pausedTime;
分享到:
评论
2 楼 修博龙泉 2013-05-13  
旋转view:
  CGAffineTransform at =CGAffineTransformMakeRotation(M_PI/2);//先顺时钟旋转90
//    at =CGAffineTransformTranslate(at,200,0);
    [self.image setTransform:at];
1 楼 修博龙泉 2013-05-13  
阻尼效果图片:
CALayer *layer = self.image.layer;
    CAKeyframeAnimation *animation;
    animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
    animation.duration = 0.5f;
    animation.cumulative = YES;
    animation.repeatCount = 1;
    animation.values = [NSArray arrayWithObjects:   	// i.e., Rotation values for the 3 keyframes, in RADIANS
                        [NSNumber numberWithFloat:0.0 * M_PI],
                        [NSNumber numberWithFloat:0.75 * M_PI],
                        [NSNumber numberWithFloat:1.5 * M_PI], nil];
    animation.keyTimes = [NSArray arrayWithObjects:     // Relative timing values for the 3 keyframes
                          [NSNumber numberWithFloat:0],
                          [NSNumber numberWithFloat:.5],
                          [NSNumber numberWithFloat:1.0], nil];
    animation.timingFunctions = [NSArray arrayWithObjects:
                                 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn],	// from keyframe 1 to keyframe 2
                                 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil];	// from keyframe 2 to keyframe 3
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    
    [layer addAnimation:animation forKey:nil];

相关推荐

Global site tag (gtag.js) - Google Analytics