UIView.Animate on backgroundcolor

Hi, I am trying to fade in and out colors on UILabels.
I use the UIView.Animate method but whatever the duration, the change occurs instantaneously:
button1.TouchUpInside += (sender, e) =>
{
UIView.Animate(5, 0, UIViewAnimationOptions.BeginFromCurrentState,
() => { label1.BackgroundColor = UIColor.Green; },
() => { });
}
};

I can rotate the label over a particular duration using a Transform, but the background color is always changed instantly.

Any help is appreciated.

Thanks,
John.

Posts

  • ThePavelThePavel USMember
    edited October 2016

    Label's background color is not animatable, I have no idea why. If you try that on a button for example, it works.

    However, this workaround did it for me:
    UIView.Animate( 5.0, 0.0, UIViewAnimationOptions.BeginFromCurrentState, () => { label1.Layer.BackgroundColor = UIColor.Green.CGColor; }, () => { } );

  • JohnMcDonaghJohnMcDonagh GBMember ✭✭

    Fantastic, that answers my problem.
    Thank you so much!

Sign In or Register to comment.