使用UIInterpolatingMotionEffect可以使页面随着设备在空间的移动而发生微移。
UIInterpolatingMotionEffect *interpolationHorizontal = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
interpolationHorizontal.minimumRelativeValue = @(-13);
interpolationHorizontal.maximumRelativeValue = @(13);
UIInterpolatingMotionEffect *interpolationVertical = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
interpolationVertical.minimumRelativeValue = @(-13);
interpolationVertical.maximumRelativeValue = @(13);
[self.view addMotionEffect:interpolationHorizontal];
[self.view addMotionEffect:interpolationVertical];
作者:iOS_小松哥
链接:https://www.jianshu.com/p/4523eafb4cd4
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
网友评论