我不想为箭头形状的 View 设置动画,我希望它从左到右、从左到右等等设置动画。
下面的代码不起作用,我猜我需要一个路径,但不知道如何在 UIView block 动画中执行此操作。
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationOptionRepeat animations:^{
controller.view.frame = frame1;
controller.view.frame = frame2;
} completion:^(BOOL finished) {
}];
最佳答案
您可以使用UIViewAnimationOptionAutoreverse
选项,试试下面的代码:
UIView * testView = [[UIView alloc] initWithFrame:CGRectMake(20.0f, 100.0f, 300.0f, 200.0f)];
[testView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:testView];
[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{
[testView setFrame:CGRectMake(0.0f, 100.0f, 300.0f, 200.0f)];
}
completion:nil];
[testView release];
它会从右到左,从左到右,...平稳地重复移动。
关于ios - UIView block 动画从左到右和向左移动 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8675859/