gpt4 book ai didi

objective-c - 如何为原点设置动画?

转载 作者:行者123 更新时间:2023-12-01 19:17:58 33 4
gpt4 key购买 nike

我想根据左上点(原点)的值对 View 的位置进行动画处理。我都试过了

CGPoint myPosition = CGPointMake(0, 500);
CABasicAnimation *yAnimation = [CABasicAnimation animationWithKeyPath:@"frameOrigin"];
yAnimation.toValue = [NSValue valueWithCGPoint:myPosition];


CGPoint myPosition = CGPointMake(0, 500);
CABasicAnimation *yAnimation = [CABasicAnimation animationWithKeyPath:@"origin"];
yAnimation.toValue = [NSValue valueWithCGPoint:myPosition];

没有任何效果。如何正确设置此属性的动画?

最佳答案

如果您只想为 View 的位置设置动画,请查看 UIViewAnimation并使用它的 block 。

[UIView animateWithDuration:.7
animations:^{
//what you would like to animate
myView.frame = CGRectMake(myView.frame.origin.x + 100,myView.frame.origin.y + 100, myView.frame.size.width, myView.frame.size.height);
}completion:^(BOOL finished){
//do something when the animation finishes
}];

关于objective-c - 如何为原点设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11933486/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com