我想要做的是左右旋转视图,同时上下移动它的位置。
这是我的代码:
CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-12.0));
CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(12.0));
flyingGuy.transform = leftWobble; // starting point
[UIView beginAnimations:@"wobble" context:flyingGuy];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:1000];
[UIView setAnimationDuration:1.3];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)];
flyingGuy.transform = rightWobble;
CGRect frame = flyingGuy.frame;
frame.origin.y += 10;
[flyingGuy setFrame:frame];
[UIView commitAnimations];
- (void)wobbleEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([finished boolValue]) {
UIView* item = (UIView *)context;
item.transform = CGAffineTransformIdentity;
}
}
使用当前代码,视图大小会随着向上或向下移动而变化。有什么建议么?