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. EF - Code First 开发方式

    概述: 本节介绍通过 Code First 开发建立新数据库. 借助 Code First 可以选择使用类的特性和属性执行配置,或者使用 XML 配置文件来配置,当然也可以使用 Fluent API ...

  2. GET 和 POST 的区别 以及为什么 GET请求 比 POST请求 更快

    引子: 和朋友的聊天中得知他公司后台接口全部都是 POST 请求, 我表示很纳闷为什么全是 POST 请求呢? GET 比 POST 安全,或者说 便于后台方便,后台不用区分包装类  (所以全部用 P ...

  3. js promise中如何取到[[PromiseValue]]

    返回的值Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: "http://dl.stream.qqmus ...

  4. Ubuntu连网的问题

    Ubuntu一直提示网络offline,disconnection 首先,进入了无线网络,进入属性,允许其他网络用户通过此计算机的Internet连接: 但是虚拟机仍显示网络未连接:(不知道此步骤是不 ...

  5. ubuntu安装smartGit

    1.首先安装jdk:(http://www.cnblogs.com/xiaochou/p/install_mint.html 评论区) 2.下载和安装smartGit: http://www.synt ...

  6. day48-python爬虫学习三

    Python的urllib和urllib2模块都做与请求URL相关的操作,但他们提供不同的功能.他们两个最显着的差异如下: urllib2可以接受一个Request对象,并以此可以来设置一个URL的h ...

  7. Miller Robbin测试模板(无讲解)

    想着费马定理和二次探测定理就能随手推了. 做一次是log2n的. #include<bits/stdc++.h> using namespace std; typedef long lon ...

  8. Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load

    Oracle 11g 单实例到单实例OGG同步实施文档-OGG initial load 2018-06-07 00:514730原创GoldenGate 作者: leo 本文链接:https://w ...

  9. node-express-2-jade

    1,Jade里可以省略尖括号,直接写标签名 2,标签间的嵌套关系用换行加空格来实现 3,紧接在标签名后加上.xx或#xx,就能给标签添加css类名和id,如果不写标签名默认就是div 4,标签属性写入 ...

  10. Python之字符串方法

    def capitalize(self): # 第一个字符变大写 def center(self, width, fillchar=None): # 内容居中,两端可指定内容填充 def count( ...