【发布时间】:2013-08-10 05:21:06
【问题描述】:
我从未专门在 iOS 上使用过动画,我希望能指出正确的方向。到目前为止,我已经以类似于下面的方式为一堆药丸形状的对象设置了动画,但是我还没有根据形状的 y 位置实现正确的遮罩。
药丸形状只是 UIView。我正在寻找一种方法来根据他们的定位改变他们的背景;背景本身不动,只是药丸。
编辑:
根据 Rob 在下面的回答,我现在将动画与设备的运动联系起来,如下所示:
- (void)setAnimationToDeviceMotion {
motionManager = [[CMMotionManager alloc] init];
motionManager.deviceMotionUpdateInterval = 0.1f;
NSOperationQueue *motionQueue = [[NSOperationQueue alloc] init];
[motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical toQueue:motionQueue withHandler:^(CMDeviceMotion *motion, NSError *error) {
if (!error) {
double pitch = motion.attitude.pitch;
NSLog(@"%f", pitch);
[self addMaskToView:self.imageView withAdjustment:pitch];
}
}];
}
【问题讨论】:
标签: ios animation core-animation quartz-graphics quartz-core