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. SQL Pretty Printer for SSMS 很不错的SQL格式化插件

    写SQL语句或者脚本时,看到凌乱的格式就头大了,于是决心找一款SQL语句格式化的工具. 功夫不负有心人还真的被我找到一款很好用,很方便的SQL Server插件:SQL Pretty Printer ...

  2. C#调用java包里的方法

    用IKVM,步骤: 下载ikvmbin-7.2.4630.5.zip,解压,把bin目录所在路径加到环境变量path里 2.电脑开始->CMD,输入ikvmc –out:”输出dll文件的路径” ...

  3. 微信里iphone后退不刷新问题解决方案

    $(function() { pushHistory(); }); function pushHistory() { window.addEventListener("popstate&qu ...

  4. struts标签怎么判断request里的属性是否为空 <s:if test="${list==null}"> </s:if>

    <s:if test="${weigou}==999"> //错误的 ${list==null} ,$实在strtus的配置文件中取值用的,不是在jsp页面里取值的的吧 ...

  5. 浅谈C中操作字符串函数的用法(一)

    按照内核string.h中函数的顺序进行大概的介绍,若干函数会给出一个简单的例子.有不足之处还希望各位看到的留言告知. 一.memcpy: 函数原型:extern void * memcpy(void ...

  6. DbArithmeticExpression 参数必须具有数值通用类型问题的解决

    C#中LINQ to Entities进行日期比较,使用-运算符,比如: list.FirstOrDefault(s =>(DateTime.Now - s.Updated).TotalHour ...

  7. 详解Python的作用域和命名空间

    最近在学习Python,不得不说,Python真的是一门很好用的语言.但是学习的过程中关于变量作用域(scope)的命名空间(namespace)的问题真的把我给搞懵了.在查阅了相关资料之后,觉得自己 ...

  8. spring整合redis(哨兵模式)

    首先服务器搭建哨兵模式(我这里使用的是Windows8系统),感谢两位博主,少走不少弯路,在此给出链接:服务器哨兵模式搭建和整合哨兵模式 什么一些介绍就不介绍了,可以看一下连接,比较详细,初次接触,当 ...

  9. [Leetcode 37]*数独游戏 Sudoku Solver 附解释

    [题目] 每一行.每一列.每个3*3的格子里只能出现一次1~9. [思路] 参考了思路,附加了解释. dfs遍历所有非空格子,n是已经填好的个数. 初始化条件.n=81,都填了,返回结束.对于已经填好 ...

  10. python常见问题汇总

    1.python使用selenium中的时间等待 a.强制等待 time.sleep() b.隐式等待: 如果某些元素不是立即可用的,隐式等待是告诉WebDriver去等待一定的时间后去查找元素. 默 ...