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.

How to Animate UILabel textColor Properties的更多相关文章

  1. JavaScript - 基于CSS3动画的实现

    在痛苦的IE8时代,所有的动画都只能基于自己计算相关动画属性,开定时器setTimeout/setInterval轮询动画任务. 而肩负重任的HTML5,早已注意到了日益增强的动画,随着HTML5的降 ...

  2. jsPlumb 学习笔记

    介绍 使用svg完成画图,四个概念: anchor: endpoint在的位置,可通过name访问 endpoint:connection的一端节点,通过addPoint makeSource, co ...

  3. jQuery ui背景色动态渐变导航菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. jquery-1.11.1.js

       每次想要使用这个js时,总是要到官网上下载,太麻烦,现在把它收录了 jquery-1.11.1.js /*! * jQuery JavaScript Library v1.11.1 * http ...

  5. ASP.NET之Jquery入门级别

    1.Jquery的简单介绍 1)Jquery由美国人John Resig创建.是继prototype之后又一个优秀的JavaScript框架. 2)JQuery能做什么?JQuery能做的普通的Dom ...

  6. jQuery JavaScript Library v3.2.1

    /*! * jQuery JavaScript Library v3.2.1 * https://jquery.com/ * * Includes Sizzle.js * https://sizzle ...

  7. View Programming Guide for iOS ---- iOS 视图编程指南(五)---Animations

      Animations Animations provide fluid visual transitions between different states of your user inter ...

  8. jquery2.0.3 全部源码

    /*! * Includes Sizzle.js 选择器,独立的库 * http://sizzlejs.com/ */ (function( window, undefined ) { //" ...

  9. jquery源码09 (6058 , 6620) css() : 样式的操作

    var curCSS, iframe, // swappable if display is none or starts with table except "table", & ...

随机推荐

  1. springBoot 随笔(二)

    此文为springBoot 结合 thymeleaf ,解析后台接口数据展示到html页面 基于 springBoot(一)工程. 1/ 引用 thymeleaf 组件依赖 <!-- depen ...

  2. 在vue中添加sass的配置的方法

    1.安装sass的依赖包 npm install --save-dev sass-loader //sass-loader依赖于 node-sass npm install --save-dev no ...

  3. angular ,require.js, angular-async-loader实现单页面路由,控制器js文件分离

    https://github.com/heboliufengjie/appRoute/tree/re re 分支,实现,路由配置,控制器js文件分离

  4. linux服务器用nginx做网站内页之间301的跳转方法

    例: 要将这个页面 /topic/show-228-1.html 做301跳转到 /dance/topic-show-228-1.html nginx的伪静态规则就这样写: rewrite ^/top ...

  5. JAVA中时间格式(SimpleDateFormat)和数字格式(DecimalFormat)转换详解(转)

    时间格式转换SimpleDateFormat: //定义日期的格式 SimpleDateFormat format =new SimpleDateFormat("yyMMdd"); ...

  6. [数]昨天欠下的一道立体几何题HDU-4741

    并没有做到这道题,后来听学长说了题意,总之就是立体几何嗯 看了好几份题解,是的我知道是异面线段的距离了,可是看码完全不明orz. 这时候出现了一份清晰易懂甚至给出了公式来源的blog╰(*°▽°*)╯ ...

  7. 复杂xml格式报文和实体类之间的转化

    pom.xml中引入如下依赖: <dependency> <groupId>org.eclipse.persistence</groupId> <artifa ...

  8. 数据库数据迁移 SqlServer复制到mysql

    经过一番搜索,有朋友推荐用datax的,后来发现比较麻烦,需要循环每个表去复制:有推荐用Navicat的,但是方式有点行不通,会报文件打不开:无法打开Provider=SQLNCLI10.1;Pers ...

  9. cookie路径问题

    昨天在开发过程中用到cookie,在销毁该$.cookie('flag',null)时发现又新生成了一个同名的值为null但路径不相同的cookie 原来在设置cookie时没有给他设置路径所以该co ...

  10. python threading模块中的join()方法和setDeamon()方法的一些理解

    之前用多线程的时候看见了很多文章,比较常用的大概就是join()和setDeamon()了. 先说一下自己对join()的理解吧: def join(self, timeout=None): &quo ...