Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3977242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:54:01+00:00 2026-05-20T04:54:01+00:00

I am animating the alpha of a UILabel so that it flashes white when

  • 0

I am animating the alpha of a UILabel so that it flashes white when a button is pressed. The label is pure white [r255,g255,b255,a1] to achieve the flash I am animating the CALayer opacity from 0.5 to 1.0 and then back to 0.5. The code to do this: (thanks to Dave DeLong for the help) is:

UILabel *navTitle;
@property(nonatomic, retain) UILabel *navTitle;
...
...
@synthesize navTitle;

.

// ADD ANIMATION OBJECT
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"opacity"];
[anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[anim setFromValue:[NSNumber numberWithFloat:0.5]];
[anim setToValue:[NSNumber numberWithFloat:1.0]];
[anim setAutoreverses:YES];
[anim setDuration:0.5];
[[[self navTitle] layer] addAnimation:anim forKey:@"flash"];
[[self navTitle] setTag:1138];

As the flash gets called multiple times (i.e. each time the button is pressed) I am calling removeAnimationForKey before the next flash, my question, is this correct (i.e. the bit where I remove the animation from the layer). If I did not remove the layer am I right in assuming that they will just build up as I add more and more?

// REMOVE ANIMATION OBJECT
if([[self navTitle] tag] == 1138) {
    [[[self navTitle] layer] removeAnimationForKey:@"flash"];
    [[self navTitle] setTag:0];
}

NB: The initial idea was to do a constant pulsing (on a NSTimer) but on testing a single pulse looked at lot cleaner on the UI.

EDIT:

if you try to call removeAnimationForKey for a key that does not exist what happens, currently I am checking the UILabel tag before I do the remove, do I need to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:54:02+00:00Added an answer on May 20, 2026 at 4:54 am

    I think anyway, it is not wrong, it might be that the framework does it by its own way, but doing it manually doesn’t harm it, as long as addAnimation method is a pair method with removeAnimation…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

-(void)fadeLabel{ UILabel *label = (UILabel *)[self.view viewWithTag:kLabelTag]; [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{ label.alpha =
I am animating a UIView (alpha) property and I want that after the animation
i am animating an UIImageView with an image of a circle that grows and
What i'm trying to do is animating a label when timer ticks. I have
What I want to achieve: Drawing png files with alpha exactly as it appears
I actually stuck on a problem with animating a UILabel in my iOS Application.
I have an animation that lifts up a button and drops a shadow. Here's
I'm applying an AlphaAnimation to a Button. The animation is extremely simple. <alpha xmlns:android=http://schemas.android.com/apk/res/android
I have an app that animates the alpha of some images from 0 to
I am animating an image rotation using a doubleanimation linked to a click event

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.