UILabel混合显示动画效果
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混合显示动画效果的更多相关文章
- UILabel的缩放动画效果
UILabel的缩放动画效果 效果图 源码 https://github.com/YouXianMing/Animations // // ScaleLabel.h // Animations // ...
- 高逼格UILabel的闪烁动画效果
高逼格UILabel的闪烁动画效果 最终效果图如下: 源码: YXLabel.h 与 YXLabel.m // // YXLabel.h // // Created by YouXianMing o ...
- anacoda的spyder在调用matplotlib的时候无法显示动画效果【学习笔记】
ipython console的默认设置将图像结果显示在终端,但是这样显示存在的问题是无法显示动画效果,因此需要将动画效果显示到单独的窗口,按照下面的截图即可显示. 方法一.按照如下截图显示设置,重启 ...
- jquery 隐藏 显示 动画效果
<!DOCTYPE html> <html> <head> <script src="/jquery/jquery-1.11.1.min.js&qu ...
- cad.net 图元延迟显示,动画效果,编辑器延迟发送提示.
public class Command_test { [CommandMethod("tt", CommandFlags.Modal | CommandFlags.UsePick ...
- iframe载入页面过程显示动画效果
http://www.xfeixiang.com/Bug/Detail/A2FD7EFFA8CA72F1
- 设置Activity显示和关闭时的动画效果
设置Activity显示和关闭时的动画效果 通过overridePendingTransition方法可以设置Activity显示和关闭的动画效果.首先需要在res/anim目录中建立相应的动画资源文 ...
- UI设计篇·入门篇·简单动画的实现,透明动画/旋转动画/移动动画/缩放动画,混合动画效果的实现,为动画设置监听事件,自定义动画的方法
基本的动画构成共有四种:透明动画/旋转动画/移动动画/缩放动画. 配置动画的方式有两种,一种是直接使用代码来配置动画效果,另一种是使用xml文档配置动画效果 相比而言,用xml文档写出来的动画效果,写 ...
- Android ListView item项 显示动画
(1)使用LayoutAnimation 所谓的布局动画,其实就是为ViewGroup添加显示动画效果,主要用过LayoutAnimationController来控制实现.LayoutAnimati ...
随机推荐
- .net/c#常用框架/中间件简介
任务调度 Quartz.NET:Quartz.NET是一个开源的作业调度框架,非常适合在平时的工作中,定时轮询数据库同步,定时邮件通知,定时处理数据等. Quartz.NET允 许开发人员根据时间间隔 ...
- CCF CSP 201503-4 网络延时
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201503-4 网络延时 问题描述 给定一个公司的网络,由n台交换机和m台终端电脑组成,交换机 ...
- canvas 笔记整理
canvas Retina 屏幕优化 /** * HiDPI Canvas Polyfill (1.0.9) * * Author: Jonathan D. Johnson (http://jonda ...
- 【LOJ】#2340. 「WC2018」州区划分
题解 学习一个全世界人都会只有我不会的东西 子集变换! 难道我要把这题当板子讲?等等这题好像是板...WC出板题好刺激啊= = 假装我们都做过HAOI2015的FMT题,我们都知道一些FMT怎么解决或 ...
- Ionic入门四:卡片
近年来卡片(card)的应用越来越流行,卡片提供了一个更好组织信息展示的工具. 针对移动端的应用,卡片会根据屏幕大小自适应大小. 我们可以很灵活的控制卡片的显示效果,甚至实现动画效果. 卡片一般放在页 ...
- [ 转载 ] Java基础14--创建线程的两个方法
http://www.cnblogs.com/whgw/archive/2011/10/03/2198506.html Java提供了线程类Thread来创建多线程的程序.其实,创建线程与创建普通的类 ...
- android 视频
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 第一套完整版: 第二套完整版: 第三套完整版: 第四套完整版: 第五套完整版: ==== ...
- [BZOJ5317][JSOI2018]部落战争(闵可夫斯基和)
对于点集$A$,$B$,闵可夫斯基和$C=\{(x1+x2,y1+y2)|(x1,x2)\in A,(y1,y2)\in B\}$.由此可知,对于两个凸包$A$,$B$的闵可夫斯基和$C$满足,$C$ ...
- JavaScript 继承和数组
前言 因为篇幅比较短,所以将JavaScript中的继承和数组进行统一写. 继承 当一个函数对象被创建的时候,Function构造器产生的函数对象会运行类似这样的代码: this.prototype ...
- HDU 5682 zxa and leaf 二分 树形dp
zxa and leaf 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5682 Description zxa have an unrooted t ...