UILabel的缩放效果
来源:互联网 发布:淘宝是猫京东是狗 编辑:程序博客网 时间:2024/05/16 20:29
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 = 0; _colorLabel.alpha = 0; _backedLabel.textAlignment = NSTextAlignmentCenter; _colorLabel.textAlignment = NSTextAlignmentCenter; [self addSubview:_backedLabel]; [self addSubview:_colorLabel]; } return self;}- (void)startAnimation { if (_endScale == 0) { _endScale = 2.f; } [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:7 initialSpringVelocity:4 options:UIViewAnimationOptionCurveEaseInOut animations:^{ _backedLabel.alpha = 1.f; _backedLabel.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0); _colorLabel.alpha = 1.f; _colorLabel.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);; } completion:^(BOOL finished) { [UIView animateWithDuration:2 delay:0.5 usingSpringWithDamping:7 initialSpringVelocity:4 options:UIViewAnimationOptionCurveEaseInOut animations:^{ _colorLabel.alpha = 0.f; _colorLabel.transform = CGAffineTransformMake(_endScale, 0, 0, _endScale, 0, 0); } 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, 0, 0, startScale, 0, 0); _colorLabel.transform = CGAffineTransformMake(startScale, 0, 0, startScale, 0, 0);}- (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
细节
标签: iOS, 重要, 效果, 动画, 动画项目合集系列
好文要顶 已关注 收藏该文
0
0
(请您对文章做出评价)
« 上一篇:产生渐变色的view
» 下一篇:制作 OS X El Capitan 启动盘
» 下一篇:制作 OS X El Capitan 启动盘
posted @ 2015-12-17 20:00 YouXianMing 阅读(129) 评论(0) 编辑 收藏
0 0
- UILabel的缩放效果
- UILabel的效果
- UIView缩放的动画效果
- UILabel的混合显示动画效果
- iOS 实现UILabel的跑马灯效果
- JavaScript图片 向下闪缩放的效果
- css3 ----input focus的发光,缩放 效果
- jQuery实现图片展开缩放的效果
- UIView大小缩放的动画效果函数
- 仿携程首页缩放的点击效果
- iOS UIView简单的缩放动画效果
- 视图响应触摸事件的缩放效果
- UILabel添加发光效果
- UILabel发光字效果
- UILabel描边效果
- 一个简单的例子,实现UILabel阴影效果
- iOS UILabel复制粘贴效果
- UILabel换行显示 效果如下
- WebService学习笔记-添加拦截器到基于Spring的Webservice
- WebService学习笔记-Ajax请求Webservice
- WebService学习笔记-Ajax通过servlet请求跨域Webservice
- JUnit学习笔记-入门介绍
- UML学习笔记
- UILabel的缩放效果
- JavaScript DOM编程 学习笔记
- JavaScript DOM编程 学习笔记-获取元素节点
- JAVA基础内容自己的分析
- JavaScript DOM编程 学习笔记-两个小示例
- JavaScript DOM编程 学习笔记-节点属性
- JavaScript DOM编程 学习笔记-创建并接入节点
- JavaScript DOM编程 学习笔记-替换节点
- JavaScript DOM编程 学习笔记-删除节点