使用动画更改 UITextView 文本颜色

发布于 2024-08-30 22:44:10 字数 263 浏览 4 评论 0原文

只是一个简单的问题。 是否可以用动画更改 UITextView 的文本颜色?

[UITextView beginAnimations:nil context:NULL]; 
[UITextView setAnimationDuration:2.0]; 
     textView.textColor = [UIColor grayColor];  
[UITextView commitAnimations];   

干杯!
- 马丁

Just a simple question.
Is it possible to change the text color of UITextView with a animation?

[UITextView beginAnimations:nil context:NULL]; 
[UITextView setAnimationDuration:2.0]; 
     textView.textColor = [UIColor grayColor];  
[UITextView commitAnimations];   

Cheers!
- Martin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

待天淡蓝洁白时 2024-09-06 22:44:10

从 iOS 4.0 开始,您现在可以使用 [UIViewtransitionWithView:duration:options:animations:completion:] 来实现此目的

[UIView transitionWithView:textView
                  duration:0.5f
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    textView.textColor = ...
                }
                completion:nil];

Since iOS 4.0 you can now achieve this using [UIView transitionWithView:duration:options:animations:completion:]

[UIView transitionWithView:textView
                  duration:0.5f
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    textView.textColor = ...
                }
                completion:nil];
撩发小公举 2024-09-06 22:44:10

textColor 不是一个可动画的属性,所以我认为这对于 UITextView 来说是不可行的。

The textColor is not an animatable property, so I don't think this will be feasible with the UITextView.

二货你真萌 2024-09-06 22:44:10

正如 Martin Cote 所说,textColor 不是一个可设置动画的属性。
我通过更改 UItextView 透明度解决了这个问题。

[UITextView beginAnimations:nil context:NULL]; 
[UITextView setAnimationDuration:2.0]; 
     textView.alpha = 0.5f; 
[UITextView commitAnimations]; 

感谢您抽出时间。
/ 马丁

As Martin Cote said textColor is not an animatable property.
I solved this with a change to the UItextView transparency instead.

[UITextView beginAnimations:nil context:NULL]; 
[UITextView setAnimationDuration:2.0]; 
     textView.alpha = 0.5f; 
[UITextView commitAnimations]; 

Thanks for your time.
/ martin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文