[iOS]UIInterpolatingMotionEffect重力视觉差

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. self.view.backgroundColor = [UIColor grayColor]; UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
view.backgroundColor = [UIColor blueColor];
view.layer.borderColor = [[UIColor greenColor] CGColor];
view.layer.borderWidth = 5.0;
[self.view addSubview:view]; // 创建偏移
UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x"
type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y"
type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; // 设置最大值和最小值
effectX.maximumRelativeValue = @();
effectX.minimumRelativeValue = @(-);
effectY.maximumRelativeValue = @();
effectY.minimumRelativeValue = @(-); [view addMotionEffect:effectX];
[view addMotionEffect:effectY];
}

初始效果图

[iOS]UIInterpolatingMotionEffect重力视觉差

倾斜屏幕后效果图

[iOS]UIInterpolatingMotionEffect重力视觉差

[iOS]UIInterpolatingMotionEffect重力视觉差

上一篇:JavaSE中常见的工具类


下一篇:.NET破解之100%营销QQ辅助软件【更新】