ios - 我可以使用 setAnimationRepeatCount : within a UIView animation block?
<p><p>我想使用 UIAnimation 的 block 样式方法使按钮闪烁,特别是:</p>
<pre><code>animateWithDuration:delay:options:animations:completion
</code></pre>
<p>我认为我需要设置的一件事是“AnimationRepeatCount”属性 - 可以像这样在动画 block 代码中设置吗?</p>
<pre><code>- (void)animateItemWithBlinking:(BOOL)blinking {
__block BOOL isInBlinkState = blinking;
if (!isBlinking)
{
// Start blinking
[UIView animateWithDuration:0.50f
delay:0
options:UIViewAnimationCurveLinear
animations:^{
// Can I call the AnimationRepeat setter here or
// should it be elsewhere outside this block?
;
;
;
} completion:^(BOOL finished) {
// eventually, this is a value that I want the method to return
isInBlinkState = !isInBlinkState;
}];
}
else
{
// Stop blinking
[UIView animateWithDuration:0.30f
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
// Stop blinking - reset everything
;
;
;
} completion:^(BOOL finished) {
// eventually, this is a value that I want the method to return
isInBlinkState = !isInBlinkState;
}];
}
}
</code></pre>
<p>在基于 block 的调用之前,我原来的方法是这样的:</p>
<pre><code>- (void)animateItemWithBlinking:(BOOL) blinking {
;
;
;
if( !blinking ) {
// Start it
;
;
;
} else {
// Stop it
;
;
;
}
blinking = !blinking;
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>是的,您可以将它设置在 block 内,它会按照您的预期进行。</p></p>
<p style="font-size: 20px;">关于ios - 我可以使用 setAnimationRepeatCount : within a UIView animation block?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8595907/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8595907/
</a>
</p>
页:
[1]