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 ...
随机推荐
- linux 101 hacks 2date,grep,find
感觉挨个按着作者来的太蠢了,我还是放自己觉得不错的东西把 用特定格式显示当前时间 以下的方法可以用各种不同的格式来显示当前时间: $ date Thu Jan :: PST $ date --date ...
- poj1251 Jungle Roads(Prime || Kruskal)
题目链接 http://poj.org/problem?id=1251 题意 有n个村庄,村庄之间有道路连接,求一条最短的路径能够连接起所有村庄,输出这条最短路径的长度. 思路 最小生成树问题,使用普 ...
- elasticsearch-.yml(中文配置详解)
此elasticsearch-.yml配置文件,是在$ES_HOME/config/下 elasticsearch-.yml(中文配置详解) # ======================== El ...
- Linux-CentOs7-svn安装及钩子配置
做个svn的教程 首先进入test目录下,新建一个svn目录,准备做svn测试cd /testmkdir svncd svn然后使用yum安装svn,这里就不使用编译安装了,这玩意只要能用就行,版本无 ...
- [ 原创 ]学习笔记-Android中隐式Intent 的使用
Android中Intent的使用分为显示Intent和隐式Intent 之前已经介绍过显示Intent的用法了,今天来介绍一下隐式Intent的用法. 当我们在使用一款软件时,如果需要从该软件内部开 ...
- eventbus 视频
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 尚硅谷Android视频<EventBus>_腾讯课堂
- 概率论与数理统计基础<1>:随机事件与随机变量
Part1. 随机事件 1-1.随机试验 随机试验:可以在相同条件下重复进行,每次试验的结果不止一个,事先知道所有可能的结果但不确定是哪一个的试验. 举例:重复的抛出一枚均匀的硬币就是一个随机试验,事 ...
- 【2016NOIP十连测】【test4】【状压DP】【容斥原理】巨神兵
题目大意: 给一个n个点(n<=17),m条边的有向图(无自环.无重边),求其无环子图的方案数. 题解: 看到n<=17,显然是用状压dp. 用f[i]表示点集i的满足条件的方案数. 状态 ...
- bzoj 1875: [SDOI2009]HH去散步 -- 矩阵乘法
1875: [SDOI2009]HH去散步 Time Limit: 20 Sec Memory Limit: 64 MB Description HH有个一成不变的习惯,喜欢饭后百步走.所谓百步走, ...
- Codeforces Round #359 (Div. 1) A. Robbers' watch 暴力
A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who att ...