XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
posts - 171,  comments - 1171,  trackbacks - 0
公告

How to Animate UILabel Properties

 

UILabel properties cannot be easy animated due to some various reasons, so code like this will have no effect on it:

1
2
3
4
5
6
7
self.someLabel.textColor = [UIColor blueColor];

[UIView animateWithDuration:0.3
                  animation:^{
  
                      self.someLabel.textColor = [UIColor redColor];
                  }];

But there is a simple solution. Instead of animating property we will perform transition on object itself.

Using transitionWithView should solve our problem:

1
2
3
4
5
6
7
8
9
10
self.someLabel.textColor = [UIColor blueColor];

[UIView transitionWithView:self.someLabel
                  duration:0.3
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{

                      self.someLabel.textColor = [UIColor redColor];

                } completion:nil];

This creates nice fade in/out animation which is exactly what we want.

posted on 2017-03-20 17:03 不及格的程序员-八神 阅读(...) 评论(...) 编辑 收藏