使用圖像到目前爲止,我有以下代碼,以動畫的圖像晃動:在Xcode
-(void)shakeView {
CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"];
[shake setDuration:0.1];
[shake setRepeatCount:2];
[shake setAutoreverses:YES];
[shake setFromValue:[NSValue valueWithCGPoint:
CGPointMake(image.jpg.center.x - 5,image.center.y)]];
[shake setToValue:[NSValue valueWithCGPoint:
CGPointMake(image.jpg.center.x + 5, image.jpg.center.y)]];
[image.jpg.layer addAnimation:shake forKey:@"position"];
}
不過,我得到以下錯誤:未聲明的標識符「image.jpg文件」的使用。 我需要做些什麼來解決這個問題?任何幫助表示讚賞。謝謝!