UILabel的缩放动画效果
UILabel的缩放动画效果
效果图
源码
https://github.com/YouXianMing/Animations
//
// ScaleLabel.h
// Animations
//
// Created by YouXianMing on 15/12/17.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import <UIKit/UIKit.h> @interface ScaleLabel : UIView /**
* Label's text.
*/
@property (nonatomic, strong) NSString *text; /**
* Label's color.
*/
@property (nonatomic, strong) UIFont *font; /**
* The Label's scale before the animation start.
*/
@property (nonatomic, assign) CGFloat startScale; /**
* The label's scale after the animation ended.
*/
@property (nonatomic, assign) CGFloat endScale; /**
* The show label's color.
*/
@property (nonatomic, strong) UIColor *backedLabelColor; /**
* The animated label's color.
*/
@property (nonatomic, strong) UIColor *colorLabelColor; /**
* Start animation.
*/
- (void)startAnimation; @end
//
// ScaleLabel.m
// Animations
//
// Created by YouXianMing on 15/12/17.
// Copyright © 2015年 YouXianMing. All rights reserved.
// #import "ScaleLabel.h" @interface ScaleLabel () @property (nonatomic, strong) UILabel *backedLabel;
@property (nonatomic, strong) UILabel *colorLabel; @end @implementation ScaleLabel - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _backedLabel = [[UILabel alloc] initWithFrame:self.bounds];
_colorLabel = [[UILabel alloc] initWithFrame:self.bounds]; _backedLabel.alpha = ;
_colorLabel.alpha = ; _backedLabel.textAlignment = NSTextAlignmentCenter;
_colorLabel.textAlignment = NSTextAlignmentCenter; [self addSubview:_backedLabel];
[self addSubview:_colorLabel];
} return self;
} - (void)startAnimation { if (_endScale == ) { _endScale = .f;
} [UIView animateWithDuration: delay: usingSpringWithDamping: initialSpringVelocity: options:UIViewAnimationOptionCurveEaseInOut
animations:^{ _backedLabel.alpha = .f;
_backedLabel.transform = CGAffineTransformMake(, , , , , ); _colorLabel.alpha = .f;
_colorLabel.transform = CGAffineTransformMake(, , , , , );; } completion:^(BOOL finished) { [UIView animateWithDuration: delay:0.5 usingSpringWithDamping: initialSpringVelocity:
options:UIViewAnimationOptionCurveEaseInOut
animations:^{ _colorLabel.alpha = .f;
_colorLabel.transform = CGAffineTransformMake(_endScale, , , _endScale, , ); } completion:nil];
}];
} #pragma mark - Overwrite getter & setter methods.
@synthesize text = _text;
- (void)setText:(NSString *)text { _text = text;
_backedLabel.text = text;
_colorLabel.text = text;
} - (NSString *)text { return _text;
} @synthesize startScale = _startScale;
- (void)setStartScale:(CGFloat)startScale { _startScale = startScale;
_backedLabel.transform = CGAffineTransformMake(startScale, , , startScale, , );
_colorLabel.transform = CGAffineTransformMake(startScale, , , startScale, , );
} - (CGFloat)startScale { return _startScale;
} @synthesize font = _font;
- (void)setFont:(UIFont *)font { _font = font;
_backedLabel.font = font;
_colorLabel.font = font;
} - (UIFont *)font { return _font;
} @synthesize backedLabelColor = _backedLabelColor;
- (void)setBackedLabelColor:(UIColor *)backedLabelColor { _backedLabelColor = backedLabelColor;
_backedLabel.textColor = backedLabelColor;
} @synthesize colorLabelColor = _colorLabelColor;
- (void)setColorLabelColor:(UIColor *)colorLabelColor { _colorLabelColor = colorLabelColor;
_colorLabel.textColor = colorLabelColor;
} @end
细节
UILabel的缩放动画效果的更多相关文章
- UILabel混合显示动画效果
UILabel混合显示动画效果 效果 源码 https://github.com/YouXianMing/Animations // // MixedColorProgressViewControll ...
- 高逼格UILabel的闪烁动画效果
高逼格UILabel的闪烁动画效果 最终效果图如下: 源码: YXLabel.h 与 YXLabel.m // // YXLabel.h // // Created by YouXianMing o ...
- AndroidUI 视图动画-缩放动画效果 (ScaleAnimation)
放动画效果,可以使用ScaleAnimation: <Button android:id="@+id/btnScale2" android:layout_width=&quo ...
- WinForm 窗口缩放动画效果
using System; using System.Collections.Generic; using System.Text; using System.Threading; using Sys ...
- POP缩放动画
POP缩放动画 效果 源码 https://github.com/YouXianMing/Animations // // SpringScaleViewController.m // Animati ...
- Android动画效果之Tween Animation(补间动画)
前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...
- Android 动画效果 及 自定义动画
1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...
- AndroidUI 布局动画-为列表添加布局动画效果
新建一个Android project ,使MainActivity 继承自 ListActivity: public class MainActivity extends ListActivity ...
- AndroidUI 视图动画-混合动画效果 (AnimationSet)/动画效果监听
在前面介绍了几种动画效果:透明动画效果(AlphsAnimation).移动动画效果(TranslateAnimation).旋转动画效果(RotateAnimation).缩放动画效果(ScaleA ...
随机推荐
- 34、疯狂java讲义第三版
内容中包含 base64string 图片造成字符过多,拒绝显示
- 企业级Docker Registry —— Harbor搭建和使用
本节内容: Harbor介绍 安装部署Harbor 环境要求 环境信息 安装部署harbor 配置harbor 配置存储 完成安装和启动harbor 访问Harbor 修改管理员密码 启动后相关容器 ...
- Retrofit + RxJava + OkHttp 让网络请求变的简单-基础篇
https://www.jianshu.com/p/5bc866b9cbb9 最近因为手头上的工作做完了,比较闲,想着做一些优化.看到以前用的那一套网络框架添加一个请求比较麻烦,并且比较难用,所以想改 ...
- Java学习(异常类)
一.什么是异常: 异常就是在运行时产生的问题.通常用Exception描述. 在java中,把异常封装成了一个类,当出现问题时,就会创建异常类对象并抛出异常相关的信息(如详细信息,名称以及异常所处的位 ...
- 修改linux下默认的python版本
首先在终端输入:python --verison 查看本机默认采用的python 版本 接着进入/usr/local/lib 目录查看当前系统中安装了多少个python版本 如果只有一个,就安装你需要 ...
- 010 secondary namenode(同步元数据和日志)
1.格式化 首先格式化之后只剩下一个根目录. 格式化后会出现元数据 集群启动之后,元数据放在内存中的(消耗内存中) 格式化后会产生镜像文件fsimage,元数据存储 启动的时候namenode会读取镜 ...
- GPS数据包格式及数据包解析
GPS数据包解析 GPS数据包解析 目的 GPS数据类型及格式 数据格式 数据解释 解析代码 结构体定义 GPRMC解析函数 GPGGA解析函数 测试样例输出 gps数据包格式 gps数据解析 车联网 ...
- jdk1.8安装后查看Java -version出错
最近在电脑行安装了多个jdk的版本 分别是jdk1.6,jdk1.7,jdk1.8三个版本,在配置环境变量的时候,选择的是jdk1.7; 但是奇怪的是,当我在cmd中输入java -version后, ...
- keystone 认证深度研究分析
一.Keystone Token深度概述 Keystone作为OpenStack项目基础认证模块,目前支持的token类型分别是uuid.pkiz.pki.fernet. 首先,简要叙述一下这四种类型 ...
- linux驱动之一语点破天机
<const 关键字> 在嵌入式系开发中,const关键字就是“只读”的意思 <为什么要ARM需要进行C语言环境的初始化> 在汇编情况下,指令的跳转,保护现场需要保存的数据 ...