Animate UILabel Properties
Không rõ vì sao mà các property của UILabel không dễ để animate, vì vậy đoạn code sau không có hiệu lực với nó:
self.someLabel.textColor = [UIColor blueColor]; [UIView animateWithDuration:0.3 animation:^{ self.someLabel.textColor = [UIColor redColor]; }];
Có một cách đơn giản để giải quyết, thay vì animate property của UILabel, ta sẽ transition UILabel như sau:
self.someLabel.textColor = [UIColor blueColor]; NSUInteger options = UIViewAnimationOptionTransitionCrossDissolve; [UIView transitionWithView:self.someLabel duration:0.3 options:options animations:^{ self.someLabel.textColor = [UIColor redColor]; } completion:nil];
Đoạn code trên tạo một fade in/out effect như ta mong muốn.