在iPhone 2.x固件中,您是否可以让iPhone在系统定义的持续时间内振动:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Run Code Online (Sandbox Code Playgroud)
在越狱手机中,您曾经可以使用MeCCA.framework来执行此操作:
MeCCA_Vibrator *v = new MeCCA_Vibrator;
v->activate(1);
sleep(5);
v->deactivate();
Run Code Online (Sandbox Code Playgroud)
但我的2.x iPhone上不存在MeCCA.framework.
我正在尝试缩小图像,更改图像,然后将其缩小.
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrink.toValue = [NSNumber numberWithDouble:0];
shrink.duration = 1;
shrink.delegate = self;
[myImageView.layer addAnimation:shrink forKey:@"shrink"];
Run Code Online (Sandbox Code Playgroud)
缩小,然后当它完成时,我改变图像,并开始增长:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
myImageView.image = [images objectAtIndex:image];
CABasicAnimation* grow = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
grow.toValue = CGAffineTransformMakeScale(1,1);
grow.delegate = self;
grow.duration = 1;
[myImageView.layer addAnimation:grow forKey:@"grow"];
}
Run Code Online (Sandbox Code Playgroud)
这在模拟器上运行得很好,但是在设备上,当收缩完成时,我得到一个全尺寸旧图像的闪光,然后成长动画以新图像开始.
知道如何摆脱闪光灯吗?
(我尝试过"removedOnCompletion = NO;"并尝试将affineTransform设置为在第一次完成后缩小尺寸,但没有太多运气.)
任何提示赞赏.
KB
编辑:
优秀!设置以下内容:
shrink.fillMode = kCAFillModeForwards;
shrink.removedOnCompletion = NO;
Run Code Online (Sandbox Code Playgroud)
删除了闪烁.谢谢,本!