UILabel混合显示动画效果

效果

源码

https://github.com/YouXianMing/Animations

//
// MixedColorProgressViewController.m
// Animations
//
// Created by YouXianMing on 16/1/5.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "MixedColorProgressViewController.h"
#import "UIView+SetRect.h"
#import "GCD.h" @interface MixedColorProgressViewController () @property (nonatomic, strong) UIView *upView;
@property (nonatomic, strong) UILabel *upLabel;
@property (nonatomic, strong) UIView *downView;
@property (nonatomic, strong) UILabel *downLabel; @property (nonatomic, strong) GCDTimer *timer; @end @implementation MixedColorProgressViewController - (void)setup { [super setup]; /*
给upView的frame值做动画才是label能够混色显示的核心 upView(红色背景) ===> upLabel(白色底字)
| |
| |
| |
| |
downView(白色背景) ===> downLabel(红色底字) */ // 上面一层
{
// 红色背景
_upView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
_upView.center = self.view.center;
_upView.layer.cornerRadius = .f;
_upView.backgroundColor = [UIColor redColor];
_upView.layer.masksToBounds = YES; // 核心(不让subview显示超出范围)
[self.view addSubview:_upView]; // 白色底字
_upLabel = [[UILabel alloc] initWithFrame:_upView.bounds];
_upLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:];
_upLabel.text = @"YouXianMing - iOS Programmer";
_upLabel.textColor = [UIColor whiteColor];
_upLabel.textAlignment = NSTextAlignmentCenter;
[_upView addSubview:_upLabel];
} // 下面一层
{
// 白色背景
_downView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
_downView.center = self.view.center;
_downView.layer.cornerRadius = .f;
_downView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_downView]; // 红色底字
_downLabel = [[UILabel alloc] initWithFrame:_downView.bounds];
_downLabel.textColor = [UIColor redColor];
_downLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:];
_downLabel.text = @"YouXianMing - iOS Programmer";
_downLabel.textAlignment = NSTextAlignmentCenter;
[_downView addSubview:_downLabel];
} // 显示上面一层
[self.view bringSubviewToFront:_upView]; // 给上面一层的frame值做动画
_timer = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]];
[_timer event:^{ [UIView animateWithDuration:0.5f delay:.f usingSpringWithDamping:.f initialSpringVelocity: options: animations:^{ _upView.width = arc4random() % ; } completion:nil]; } timeInterval:NSEC_PER_SEC];
[_timer start];
} @end

细节

UILabel混合显示动画效果的更多相关文章

  1. UILabel的缩放动画效果

    UILabel的缩放动画效果 效果图 源码 https://github.com/YouXianMing/Animations // // ScaleLabel.h // Animations // ...

  2. 高逼格UILabel的闪烁动画效果

    高逼格UILabel的闪烁动画效果 最终效果图如下: 源码: YXLabel.h 与  YXLabel.m // // YXLabel.h // // Created by YouXianMing o ...

  3. anacoda的spyder在调用matplotlib的时候无法显示动画效果【学习笔记】

    ipython console的默认设置将图像结果显示在终端,但是这样显示存在的问题是无法显示动画效果,因此需要将动画效果显示到单独的窗口,按照下面的截图即可显示. 方法一.按照如下截图显示设置,重启 ...

  4. jquery 隐藏 显示 动画效果

    <!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js&qu ...

  5. cad.net 图元延迟显示,动画效果,编辑器延迟发送提示.

    public class Command_test { [CommandMethod("tt", CommandFlags.Modal | CommandFlags.UsePick ...

  6. iframe载入页面过程显示动画效果

    http://www.xfeixiang.com/Bug/Detail/A2FD7EFFA8CA72F1

  7. 设置Activity显示和关闭时的动画效果

    设置Activity显示和关闭时的动画效果 通过overridePendingTransition方法可以设置Activity显示和关闭的动画效果.首先需要在res/anim目录中建立相应的动画资源文 ...

  8. UI设计篇·入门篇·简单动画的实现,透明动画/旋转动画/移动动画/缩放动画,混合动画效果的实现,为动画设置监听事件,自定义动画的方法

    基本的动画构成共有四种:透明动画/旋转动画/移动动画/缩放动画. 配置动画的方式有两种,一种是直接使用代码来配置动画效果,另一种是使用xml文档配置动画效果 相比而言,用xml文档写出来的动画效果,写 ...

  9. Android ListView item项 显示动画

    (1)使用LayoutAnimation 所谓的布局动画,其实就是为ViewGroup添加显示动画效果,主要用过LayoutAnimationController来控制实现.LayoutAnimati ...

随机推荐

  1. HBase(七)Hbase过滤器

    一.过滤器(Filter) 基础API中的查询操作在面对大量数据的时候是非常苍白的,这里Hbase提供了高级的查询方法:Filter.Filter可以根据簇.列.版本等更多的条件来对数据进行过滤,基于 ...

  2. Django实战(3):Django也可以有scaffold

    rails有一个无用的”神奇“功能,叫做scaffold.能够在model基础上,自动生成CRUD的界面. 说它无用,是因为rails的开发者David说,scaffold”不是应用程序开发的目的.它 ...

  3. 【Java】 int与String类型间的相互转化

    public class Test { public static void main(String[] args) { /* * int类型转String类型 */ int n1 = 9; //1. ...

  4. 2011年入侵 Kernel.org 的黑客被捕 面临10年监禁

    2011年中旬,Linux内核官网kernel.org遭到黑客入侵,攻击者植入了rootkit Phalanx,并在服务器上设置了SSH后门,kernel.org为此关闭了三周多时间.官方表示将会公开 ...

  5. spring boot thymeleaf常用方式

    动态和静态区别 静态页面的return默认是跳转到/static/index.html,当在pom.xml中引入了thymeleaf组件,动态跳转会覆盖默认的静态跳转,默认就会跳转到/template ...

  6. JAVAEE——Solr:安装及配置、后台管理索引库、 使用SolrJ管理索引库、仿京东的电商搜索案例实现

    1 学习回顾 1. Lucene  是Apache开源的全文检索的工具包 创建索引 查询索引 2. 遇到问题? 文件名 及文件内容  顺序扫描法  全文检索 3. 什么是全文检索? 这种先创建索引 再 ...

  7. iOS 11开发教程(五)iOS11模拟器介绍二

    iOS 11开发教程(五)iOS11模拟器介绍二 3.iOS11模拟器中设置语言 对于不同国家的人来说,使用到的语言是不一样的.一般情况下iOS11模拟器默认使用的English(英语).对于英文不好 ...

  8. CXF发布webservice

    http://wenku.baidu.com/link?url=dTJpXcL0TXslGAYYC6SSOrPGvjyEb974ZGx9-0dymU32YDjxuP8DwlI1sFpPCGqu_ywW ...

  9. BZOJ 3963 HDU3842 [WF2011]MachineWorks cdq分治 斜率优化 dp

    http://acm.hdu.edu.cn/showproblem.php?pid=3842 写的check函数里写的<但是应该是<=,调了一下午,我是个zz. 就是普通的斜率优化因为有两 ...

  10. 在Kali Linux上编译Windows EXP

    使用vc6.0去编译的时候,难免会出现点问题 这里找到MS11-046的exp来编译 poc地址:https://www.exploit-db.com/exploits/40564/ 首先需要安装mi ...