这是我的问题:
我有一些动画块,它们都被执行得很好。但我也希望执行一些动画,只有在特定BOOL
值为真时才会执行。
BOOL
正确地取TRUE
值,代码进入if
语句,因为我的日志评论正在打印。似乎只显示动画。我尝试过不同的CGPoint
值但仍然相同。
也许我错过了关于动画的东西。
我没有经常使用它们。 任何帮助都会很棒!
以下是代码示例:
// line 4 - second particle
UIImageView* particle8 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"particle"]];
particle8.frame = CGRectMake(p8.x, p8.y, particleWidth, particleWidth);
[self addSubview:particle8];
[UIView animateWithDuration:2
delay:0
options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionRepeat
animations:^{
particle8.frame = CGRectMake(p7.x, p7.y, particleWidth, particleWidth); }
completion:^(BOOL finished){[particle8 removeFromSuperview]; }];
if (_isSmartGridOn) {
// line 2b - first particle
UIImageView* particle9 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"particle"]];
particle9.frame = CGRectMake(ep.x - 5, ep.y - 5, particleWidth, particleWidth);
[self addSubview:particle9];
[UIView animateWithDuration:1
delay:0
options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionRepeat
animations:^{
particle9.frame = CGRectMake(p10.x, p10.y, particleWidth, particleWidth); }
completion:^(BOOL finished){[particle9 removeFromSuperview]; }];
}
答案 0 :(得分:0)
您只有错字或复制/粘贴错误:
particle8.frame = CGRectMake(p10.x, p10.y, particleWidth, particleWidth);
^ should be 9 ^^ ^^ looks like these might be wrong too