美文网首页iosiOS_UIKit
UIInterpolatingMotionEffect视觉运动效

UIInterpolatingMotionEffect视觉运动效

作者: 絮语时光杨 | 来源:发表于2018-05-14 13:46 被阅读0次

    // 设置在x轴的偏移范围
    UIInterpolatingMotionEffect * fairyEffX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];// type表示沿水平方向运行效果
    fairyEffX.maximumRelativeValue = @(50);
    fairyEffX.minimumRelativeValue = @(-50);
    // 为view添加运动效果
    [imageview addMotionEffect:fairyEffX];

    UIInterpolatingMotionEffect * fairyEffY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
    fairyEffY.maximumRelativeValue = @(50);
    fairyEffY.minimumRelativeValue = @(-50);
    [imageview addMotionEffect:fairyEffY];
    
    // 设置背景的运动效果 ===== BEGIN =====
    UIInterpolatingMotionEffect * backEffX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];// type表示沿水平方向运行效果
    backEffX.maximumRelativeValue = @(-100);
    backEffX.minimumRelativeValue = @(100);
    [self.back addMotionEffect:backEffX];
    
    UIInterpolatingMotionEffect * backEffY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
    backEffY.maximumRelativeValue = @(-100);
    backEffY.minimumRelativeValue = @(100);
    [backimageview addMotionEffect:backEffY];
    

    相关文章

      网友评论

        本文标题:UIInterpolatingMotionEffect视觉运动效

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