Using Motion Effects

2017-04-29  本文已影响0人  事件_666

文档说只有动画的属性可以用这个类
直接上高手的代码吧
// 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];
上一篇下一篇

猜你喜欢

热点阅读