美文网首页
Using Motion Effects

Using Motion Effects

作者: 事件_666 | 来源:发表于2017-04-29 19:08 被阅读0次

    文档说只有动画的属性可以用这个类
    直接上高手的代码吧
    // Do any additional setup after loading the view, typically from a nib.

    //Min and max values -- The higher these #s are, the more pronouced the effect
    CGFloat leftRightMin = -55.0f;
    CGFloat leftRightMax = 55.0f;
    
    CGFloat upDownMin = -35.0f;
    CGFloat upDownMax = 35.0f;
    
    //Motion Effect
    UIInterpolatingMotionEffect * leftRight = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
    
    leftRight.minimumRelativeValue = @(leftRightMin);
    leftRight.maximumRelativeValue = @(leftRightMax);
    
    
    UIInterpolatingMotionEffect * upDown = [[UIInterpolatingMotionEffect alloc]initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
    
    upDown.minimumRelativeValue = @(upDownMin);
    upDown.maximumRelativeValue = @(upDownMax);
    
    //Create a motion effect group
    UIMotionEffectGroup * meGroup = [[UIMotionEffectGroup alloc]init];
    meGroup.motionEffects = @[leftRight, upDown];
    
    //Add the motion effect group to our imageView
    [myImageView addMotionEffect:meGroup];
    

    相关文章

      网友评论

          本文标题:Using Motion Effects

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