使用核心动画闪烁 UILabel 问题



我想要一个使用核心动画闪烁的文本。我输入了以下代码,但我没有看到文本,也没有看到它闪烁。

// Create a blinking text
UILabel* labelText = [[UILabel alloc] initWithFrame:CGRectMake(355, 490, 400, 50)];
labelText.text = @"Tap to start";
labelText.backgroundColor = [UIColor clearColor];
[self.view addSubview:labelText];

void (^animationLabel) (void) = ^{
        labelText.alpha = 1;
};
void (^completionLabel) (BOOL) = ^(BOOL f) {
        labelText.alpha = 0;
};
NSUInteger opts =  UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat;
[UIView animateWithDuration:1.f delay:0 options:opts
                     animations:animationLabel completion:completionLabel];

知道吗?我真的看不出我的方法有什么问题。

有点愚蠢的错误,但很高兴将来知道 - 代码应该是

void (^animationLabel) (void) = ^{
        labelText.alpha = 0;
    };
    void (^completionLabel) (BOOL) = ^(BOOL f) {
        labelText.alpha = 1;
    }; 

由于 alpha 必须设置为 0,因此它应该是动画块的一部分,而不是完成块的一部分。

最新更新