UIView.animate not Animating

uiview animatewithduration duration not working
uiview animate delay not working
uiview.animate options
uiview animate frame
uiview slide down animation swift
uiview.animate completion
uiview animation from bottom to top swift
stop uiview animation swift

I am trying to animate UILabel textColor changes using UIView.animate. However, nothing is changing when I attempt to use UIView. Here is my code:

titleLabel.textColor = UIColor(red: 104/250, green: 155/250, blue: 121/250, alpha: 1)
UIView.animate(withDuration: 1.0, animations: {
    self.titleLabel.textColor = UIColor(red:206/255, green: 206/255, blue: 206/255, alpha: 1.0)

I expect the color of the label to change to a greenish color and then change back to the gray-ish color it was before. Thanks in advance for helping!

The textColor property is not specified as being animatable in Apple developer docs, so I don't think you can do it with a simple UIView animations block.

You can use UIView transition instead.

Code:

UIView.transition(with: self.titleLabel, duration: 1.0, options: .transitionCrossDissolve, animations: {
            self.titleLabel.textColor = UIColor(red: 104/250, green: 155/250, blue: 121/250, alpha: 1)
        }, completion: { _ in
            self.titleLabel.textColor = UIColor(red:206/255, green: 206/255, blue: 206/255, alpha: 1.0)
        })

I hope it will help you. Let me know if you are still having any issue.

Basic UIView Animation Tutorial: Getting Started, Animation in iOS is done by starting an animation block, then telling iOS what let viewToAnimate = UIView() UIView.animate(withDuration: 1)� I am making a messaging app. When the keyboard is shown, I want the UITextField to move up along with it, just as it does in the Messages app. However, my animation call is not working. It does not animate the textInputView as it should, but still calls the completion block after:

try

 UIView.animate(withDuration: 1.0, animations: {
        self.titleLabel.textColor = UIColor(red:206/255, green: 206/255, blue: 206/255, alpha: 1.0)
        self.view.layoutIfNeeded()
    }

How to animate views using animate(withDuration:), This block has no return value and takes a single Boolean argument that indicates whether [UIView animateWithDuration:0.2 animations:^{view.alpha = 0.0;}� Uiview animatewithduration duration not working. UIView.animateWithDuration Not Animating Swift (again), Theoretically this should not be needed if you just change the .alpha value, but maybe this could be the problem in this repeatCount = 2; animation.duration = 0.07; return animation; } The animation won't work if you call UIView.animate(.

TextColor is not supposed to be animatable in the documentation so you have to perform below animation code.

Reason:

The reason that textColor is not animatable is that UILabel uses a regular CALayer instead of a CATextLayer. so you have two options

  1. perform animation on CATextLayer
  2. Add custom animation layer as given below in the code.
let changeColor = CATransition() 

changeColor.duration = 1

CATransaction.begin()

CATransaction.setCompletionBlock {
self.titleLabel.layer.add(changeColor, forKey: nil)
self.titleLabel.textColor = UIColor(red:206/255, green: 206/255, blue: 206/255, alpha: 1.0) }

titleLabel.textColor = UIColor(red: 104.0/255.0, green: 155.0/255.0, blue: 121.0/255.0, alpha: 1.0)

CATransaction.commit()

animateWithDuration:animations:completion:, class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Void) This block takes no parameters and has no return value. class func animate(withDuration: TimeInterval, delay: TimeInterval, options: UIView. A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle.

animate(withDuration:animations:), Build and run your project to see your first animation. Did nothing happen? Were there absolutely no animations? Constraints are handled by� Adding keyframes causes the animation to animate the view from its current value to the value of the first keyframe, then to the value of the next keyframe, and so on at the times you specify. If you do not add any keyframes in the animations block, the animation proceeds from start to end like a standard animation block.

Constraint Animations on iOS Apps using XCode and Swift, settingsView.center.x = center return }, completion: nil) UIView. animateWithDuration(0.5, delay: 0.8, options: UIViewAnimationOptions. CurveEaseIn, animations:� The UIViewAnimating protocol defines the methods for implementing the basic flow control for animations, including the ability to start, stop, and pause animations. There are also several properties for reflecting the current state of the animation and for modifying that state while an animation is in progress.

Animations not working in viewDidLoad after segue. : swift, The animation is a very important element in the development of is an object of NSLayoutConstraint, UIView.animate does not work for it. The option to not inherit the animation type or any options. UIView Animation Option Curve Ease In Out Specify an ease-in ease-out curve, which causes the animation to begin slowly, accelerate through the middle of its duration, and then slow again before completing.

Comments
  • Can you post screen record what is showing right now? Does Animation not working ?
  • @AmirKhan Yes, the animation is just not working. It's nothing special.
  • Got your point. You want a simple color transformation. Check my answer below.