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的缩放动画效果的更多相关文章

  1. UILabel混合显示动画效果

    UILabel混合显示动画效果 效果 源码 https://github.com/YouXianMing/Animations // // MixedColorProgressViewControll ...

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

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

  3. AndroidUI 视图动画-缩放动画效果 (ScaleAnimation)

    放动画效果,可以使用ScaleAnimation: <Button android:id="@+id/btnScale2" android:layout_width=&quo ...

  4. WinForm 窗口缩放动画效果

    using System; using System.Collections.Generic; using System.Text; using System.Threading; using Sys ...

  5. POP缩放动画

    POP缩放动画 效果 源码 https://github.com/YouXianMing/Animations // // SpringScaleViewController.m // Animati ...

  6. Android动画效果之Tween Animation(补间动画)

    前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...

  7. Android 动画效果 及 自定义动画

    1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...

  8. AndroidUI 布局动画-为列表添加布局动画效果

    新建一个Android project ,使MainActivity 继承自 ListActivity: public class MainActivity extends ListActivity ...

  9. AndroidUI 视图动画-混合动画效果 (AnimationSet)/动画效果监听

    在前面介绍了几种动画效果:透明动画效果(AlphsAnimation).移动动画效果(TranslateAnimation).旋转动画效果(RotateAnimation).缩放动画效果(ScaleA ...

随机推荐

  1. 在Visio里加上、下标方法

    添加上标:选中要成为上标的文字,ctrl+shift+“=” 添加下标:选中要成为下标的文字,ctrl+“=”

  2. hdu 3951 硬币围成一圈(博弈)

    n个硬币围成一个环 每次只能取1-K个硬币 最后取完者胜 假如5个硬币 每次取1-2个情况1 先手取1个 后手取剩下4个中间2个 破坏了连续 虽然最后剩2个,但先手只能取一个 然后后再取一个 后手胜 ...

  3. 《精通Python设计模式》学习结构型之外观模式

    这个我在工作中也有所应用的. 就是在真正的实现层上面,再封装一个函数的调用的. 这样就可以在内层函数作真正实现, 而外层调用函数对外开放, 隔离内外的变化性. from enum import Enu ...

  4. Linux下安装Zookeeper

    Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...

  5. OSPF详解

    OSPF 详解 (1) [此博文包含图片] (2013-02-04 18:02:33) 转载 ▼ 标签: 端的 第二 以太 第一个 正在 目录 序言 初学乍练 循序渐进学习OSPF 朱皓 入门之前 了 ...

  6. synchoronized和lock区别

    synchoronized是JVM的内置锁,而lock是Java代码实现的.lock是sync对的扩展,完全可以替代后者.lock可以重入,允许同一个线程连续多次获得同一把锁.其次,lock独有的功能 ...

  7. perf工具crash的问题

    perf抓取时系统crash的情况.找前同事了解到perf工具导致系统crash的一种情况, perf工具默认是使用cycles,这个硬件事件是使用NMI,可能会导致内核错误. 之前文档上的perf命 ...

  8. luoguP2231 [HNOI2002]跳蚤

    题目链接 bzoj1220: [HNOI2002]跳蚤 题解 根据裴蜀定理,不定方程的解为未知数的gcd,所以选取的n个数的gcd为1 那么n - 1个数保证没有公约数为m的约数,枚举质因数容斥 质因 ...

  9. 洛谷.4252.[NOI2006]聪明的导游(提答 直径 随机化)

    题目链接 随机化 暴力: 随便从一个点开始DFS,每次从之前得到的f[i]最大的子节点开始DFS.f[i]为从i开始(之前)能得到的最大答案. 要注意的是f[i]应当有机会从更小的答案更新, 9.10 ...

  10. Android优化之软引用和弱引用

    Java从JDK1.2版本开始,就把对象的引用分为四种级别,从而使程序能更加灵活的控制对象的生命周期.这四种级别由高到低依次为:强引用.软引用.弱引用和虚引用.这里重点介绍一下软引用和弱引用. 如果一 ...