ios5 - 使用核心动画闪烁 UILabel 问题

标签 ios5 label

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

// 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,因此它应该是动画 block 的一部分,而不是完成 block 。

关于ios5 - 使用核心动画闪烁 UILabel 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10182137/

相关文章:

ios - 带有文本编辑字段的 UIView

Swift:字符串 - 计算高度的第一个字符位置?

html - 标签跨度和斜体字体属性的奇怪行为

objective-c - 更改 UIView alpha 值

javascript - 无法从 JavaScript 获取标签

java - 是否可以在 for 循环之外适本地使用 java 标签?

android - 在应用程序标签中设置应用程序名称不起作用

ios - UITableView->编辑模式

xcode - 显示评分星星 xcode

iphone - MkAnnotation 掉落动画 iOS 6