UIView.animate not AnimatingUIColor initializer (cannot find an initializer of type 'UIColor' that accepts …) errorColor Animation of UILabel in swiftCGColor not defined for the UIColor, need to first convert colorspace. Swift 2, Xcode 7UILabel text color is lightIs it possible to make a comparison between several colors and then change it to its closest coounter part?Google Places API SwiftUIView Subclass Set Own Height + Constraints In UIViewController + Storyboard in SwiftUICollectionView Cell with a thick borderAuto Layout views with animationHow do I convert a UIColor to a 3/4/6/8 digits hexadecimal string in Swift?

How do I align equations in three columns, justified right, center and left?

How to convert to standalone document a matrix table

Rests in pickup measure (anacrusis)

Why do airplanes use an axial flow jet engine instead of a more compact centrifugal jet engine?

Logarithm of dependent variable is uniformly distributed. How to calculate a confidence interval for the mean?

General purpose replacement for enum with FlagsAttribute

Is it ok to put a subplot to a story that is never meant to contribute to the development of the main plot?

How to prevent bad sectors?

When and what was the first 3D acceleration device ever released?

Crossing US border with music files I'm legally allowed to possess

Placing bypass capacitors after VCC reaches the IC

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

Command to Search for Filenames Exceeding 143 Characters?

Can a Beholder use rays in melee range?

Is there a general effective method to solve Smullyan style Knights and Knaves problems? Is the truth table method the most appropriate one?

How can people dance around bonfires on Lag Lo'Omer - it's darchei emori?

How long does it take to crack RSA 1024 with a PC?

Infinite Sequence based on Simple Rule

What does it mean when you think without speaking?

Why colon to denote that a value belongs to a type?

How were these pictures of spacecraft wind tunnel testing taken?

Employer asking for online access to bank account - Is this a scam?

Why do Russians call their women expensive ("дорогая")?

Why is desire the root of suffering?



UIView.animate not Animating


UIColor initializer (cannot find an initializer of type 'UIColor' that accepts …) errorColor Animation of UILabel in swiftCGColor not defined for the UIColor, need to first convert colorspace. Swift 2, Xcode 7UILabel text color is lightIs it possible to make a comparison between several colors and then change it to its closest coounter part?Google Places API SwiftUIView Subclass Set Own Height + Constraints In UIViewController + Storyboard in SwiftUICollectionView Cell with a thick borderAuto Layout views with animationHow do I convert a UIColor to a 3/4/6/8 digits hexadecimal string in Swift?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















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!










share|improve this question






















  • Can you post screen record what is showing right now? Does Animation not working ?

    – Amir Khan
    Mar 24 at 7:33











  • @AmirKhan Yes, the animation is just not working. It's nothing special.

    – Matthew Kim
    Mar 24 at 14:55











  • Got your point. You want a simple color transformation. Check my answer below.

    – Amir Khan
    Mar 24 at 15:12


















2















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!










share|improve this question






















  • Can you post screen record what is showing right now? Does Animation not working ?

    – Amir Khan
    Mar 24 at 7:33











  • @AmirKhan Yes, the animation is just not working. It's nothing special.

    – Matthew Kim
    Mar 24 at 14:55











  • Got your point. You want a simple color transformation. Check my answer below.

    – Amir Khan
    Mar 24 at 15:12














2












2








2








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!










share|improve this question














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!







swift






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 7:08









Matthew KimMatthew Kim

203




203












  • Can you post screen record what is showing right now? Does Animation not working ?

    – Amir Khan
    Mar 24 at 7:33











  • @AmirKhan Yes, the animation is just not working. It's nothing special.

    – Matthew Kim
    Mar 24 at 14:55











  • Got your point. You want a simple color transformation. Check my answer below.

    – Amir Khan
    Mar 24 at 15:12


















  • Can you post screen record what is showing right now? Does Animation not working ?

    – Amir Khan
    Mar 24 at 7:33











  • @AmirKhan Yes, the animation is just not working. It's nothing special.

    – Matthew Kim
    Mar 24 at 14:55











  • Got your point. You want a simple color transformation. Check my answer below.

    – Amir Khan
    Mar 24 at 15:12

















Can you post screen record what is showing right now? Does Animation not working ?

– Amir Khan
Mar 24 at 7:33





Can you post screen record what is showing right now? Does Animation not working ?

– Amir Khan
Mar 24 at 7:33













@AmirKhan Yes, the animation is just not working. It's nothing special.

– Matthew Kim
Mar 24 at 14:55





@AmirKhan Yes, the animation is just not working. It's nothing special.

– Matthew Kim
Mar 24 at 14:55













Got your point. You want a simple color transformation. Check my answer below.

– Amir Khan
Mar 24 at 15:12






Got your point. You want a simple color transformation. Check my answer below.

– Amir Khan
Mar 24 at 15:12













3 Answers
3






active

oldest

votes


















6














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.






share|improve this answer






























    0














    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()






    share|improve this answer






























      0














      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()






      share|improve this answer























      • This works good as well, thank you!

        – Matthew Kim
        Mar 24 at 15:17











      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321483%2fuiview-animate-not-animating%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6














      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.






      share|improve this answer



























        6














        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.






        share|improve this answer

























          6












          6








          6







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 15:12









          Amir KhanAmir Khan

          1,8621826




          1,8621826























              0














              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()






              share|improve this answer



























                0














                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()






                share|improve this answer

























                  0












                  0








                  0







                  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()






                  share|improve this answer













                  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()







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 24 at 9:30









                  hammam abdulazizhammam abdulaziz

                  1




                  1





















                      0














                      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()






                      share|improve this answer























                      • This works good as well, thank you!

                        – Matthew Kim
                        Mar 24 at 15:17















                      0














                      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()






                      share|improve this answer























                      • This works good as well, thank you!

                        – Matthew Kim
                        Mar 24 at 15:17













                      0












                      0








                      0







                      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()






                      share|improve this answer













                      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()







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 24 at 10:28









                      Muhammad Waqas BhatiMuhammad Waqas Bhati

                      2,0271223




                      2,0271223












                      • This works good as well, thank you!

                        – Matthew Kim
                        Mar 24 at 15:17

















                      • This works good as well, thank you!

                        – Matthew Kim
                        Mar 24 at 15:17
















                      This works good as well, thank you!

                      – Matthew Kim
                      Mar 24 at 15:17





                      This works good as well, thank you!

                      – Matthew Kim
                      Mar 24 at 15:17

















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321483%2fuiview-animate-not-animating%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript