UIInterpolatingMotionEffect for Newbies?
Its name seems to relate with animation, but its method seems to take care of it from Apple’s documentation. This “abstract super class” (🙄?)has one task : getting the key path!
Go steps: ☞ alloc the class ☞ init with key path and motion ☞ effect type
☞set their value.
UIInterpolatingMotionEffect * xMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@”center.x” type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
xMotionEffect.minimumRelativeValue = y;
xMotionEffect.maximumRelativeValue = x;
But does it reflect the factual physics? Not sure yet. So the relative values could be arbitrary. I wrote a little method to test a Label , a imageView, and an animation drawing.
[self applyMotionEffectToView:self.apodTitle withX:@(90) andY:@(0)];
[self applyMotionEffectToView:self.beluga withX:@(-30) andY:@(50)];[self applyMotionEffectToView:lineView withX:@(-40) andY:@(15)];
If the image from imageView is aspect fill, UIInterpolatingMotionEffect expend the view bit to see what was not seen when the phone is not tilting.
Text Label adds the playfulness. The animation drawing, not sure if it does something more. The effect is cool, but it is hard to trick the mind to feel I am for real gazing into the space of ocean with a beluga from a screen sized device…🐋