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;
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
add a comment |
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
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
add a comment |
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
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
swift
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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.
add a comment |
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()
add a comment |
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
- perform animation on CATextLayer
- 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()
This works good as well, thank you!
– Matthew Kim
Mar 24 at 15:17
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 24 at 15:12
Amir KhanAmir Khan
1,8621826
1,8621826
add a comment |
add a comment |
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()
add a comment |
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()
add a comment |
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()
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()
answered Mar 24 at 9:30
hammam abdulazizhammam abdulaziz
1
1
add a comment |
add a comment |
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
- perform animation on CATextLayer
- 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()
This works good as well, thank you!
– Matthew Kim
Mar 24 at 15:17
add a comment |
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
- perform animation on CATextLayer
- 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()
This works good as well, thank you!
– Matthew Kim
Mar 24 at 15:17
add a comment |
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
- perform animation on CATextLayer
- 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()
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
- perform animation on CATextLayer
- 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()
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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