ITeye博客

动画-图片旋转

修博龙泉 · 2013-05-13 11:28 · ios开发学习相关 · 移动开发 · Markdown

旋转:


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)

  1. #2 楼 · 修博龙泉 · 2013-05-13 21:48

    旋转view:

    
      CGAffineTransform at =CGAffineTransformMakeRotation(M_PI/2);//先顺时钟旋转90
    //    at =CGAffineTransformTranslate(at,200,0);
        [self.image settransform:at];
    
    
  2. #1 楼 · 修博龙泉 · 2013-05-13 21:43

    阻尼效果图片:

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

评论功能维护中,当前仅展示历史评论。