I would like to have a text that blink using core animation. I have put the following code but I don't see the text neither see it blinking.
// 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];
any idea? I really don't see what is wrong in my approach.
Kind of stupid mistake but good to know in the future - the code should be
void (^animationLabel) (void) = ^{
labelText.alpha = 0;
};
void (^completionLabel) (BOOL) = ^(BOOL f) {
labelText.alpha = 1;
};
since the alpha have to be set to 0 it should be part of the animation block not the completion one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With