【发布时间】:2015-02-18 06:50:05
【问题描述】:
我是 iOS 新手,请有人帮助我使用贝塞尔曲线沿 90 度路径移动图像。我已经搜索过,但我的疑问还不清楚,所以请帮助我。
我已经尝试过这段代码,但我想使用贝塞尔曲线。
- (void)startApp {
UIImageView *imageToMove =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"man.jpg"]];
imageToMove.frame = CGRectMake(10, 10, 100, 100);
[self.view addSubview:imageToMove];
// Move the image
[self moveImage:imageToMove
duration:1.0
curve:UIViewAnimationCurveLinear
x:70.0
y:70.0];
}
- (void)moveImage:(UIImageView *)image
duration:(NSTimeInterval)duration
curve:(int)curve
x:(CGFloat)x
y:(CGFloat)y {
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;
// Commit the changes
[UIView commitAnimations];
}
【问题讨论】:
-
stackoverflow.com/questions/1142727/… 看到这里已经回答了
标签: ios uiimageview uibezierpath cgaffinetransform