Shimmer

shimmer是facebook出的一个用来显示微光闪烁特效的动画库,facebook出的,必属精品,你懂的。

Shimmer is an easy way to add a shimmering effect to any view in your app. It's useful as an unobtrusive loading indicator.

Shimmer was originally developed to show loading status in Paper.

Shimmer 能让你非常容易的添加微光闪烁的特效。你可以在一些不引人注目的指示器上使用。

Shimmer最开始是我在Paper上的加载条中使用了的。

Usage

To use Shimmer, create a FBShimmeringView or FBShimmeringLayer and add your content. To start shimmering, set the shimmering property to YES.

使用Shimmer,创建FBshimmeringView或者FBShimmeringLayer然后添加里的content。你可以设置shimmering属性来出发闪烁效果。

An example of making a label shimmer:

以下是简单的使用示例:

FBShimmeringView *shimmeringView = [[FBShimmeringView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:shimmeringView];UILabel *loadingLabel = [[UILabel alloc] initWithFrame:shimmeringView.bounds];
loadingLabel.textAlignment = NSTextAlignmentCenter;
loadingLabel.text = NSLocalizedString(@"Shimmer", nil);
shimmeringView.contentView = loadingLabel;// Start shimmering.
shimmeringView.shimmering = YES;

There's also an example project. In the example, you can swipe horizontally and vertically to try various shimmering parameters, or tap to start or stop shimmering. (To build the example locally, you'll need to openFBShimmering.xcworkpace rather than the .xcodeproj.)

下载的工程文件中有demo可以演示。

Installation

There are two options:

  1. Shimmer is available as Shimmer in Cocoapods.
  2. Manually add the files into your Xcode project. Slightly simpler, but updates are also manual.

Shimmer requires iOS 6 or later.

How it works

Shimmer uses the -[CALayer mask] property to enable shimmering, similar to what's described in John Harper's 2009 WWDC talk (unfortunately no longer online). Shimmer uses CoreAnimation's timing features to smoothly transition "on-beat" when starting and stopping the shimmer.

Shimmer使用了calayer的mask属性来触发闪烁特效,与WWDC talk上描述的效果类似。Shimmer使用了CoreAnimation的time特性来流畅的过度开始与结束的动画效果。

附录:

注意,这个shiimer是可以和自家产品POP动画一起使用的.

//
//  RootViewController.m
//
//  Copyright (c) 2014年 Y.X. All rights reserved.
//

#import "RootViewController.h"
#import "FBShimmeringLayer.h"
#import "CAShapeLayer+Circle.h"
#import "YXGCD.h"
#import "POP.h"@interface RootViewController ()@property (nonatomic, strong) GCDTimer  *timer;@end@implementation RootViewController- (void)viewDidLoad
{[super viewDidLoad];self.view.backgroundColor = [UIColor blackColor];// 直接使用layer层做动画FBShimmeringLayer *showLayer = [FBShimmeringLayer new];showLayer.frame = (CGRect){CGPointZero, CGSizeMake(200, 200)};showLayer.position = self.view.center;showLayer.shimmering = YES;showLayer.shimmeringBeginFadeDuration = 0.3;showLayer.shimmeringOpacity = 0.3;showLayer.shimmeringPauseDuration = 0.6f;[self.view.layer addSublayer:showLayer];// 制造形状的layerCAShapeLayer *layer = [CAShapeLayer layer];layer.lineWidth = 1.f;layer.strokeColor = [UIColor redColor].CGColor;showLayer.contentLayer = layer;// 贝塞尔曲线(创建一个圆)UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 100)radius:98.fstartAngle:DEGREES(0)endAngle:DEGREES(360)clockwise:YES];// 获取pathlayer.path = path.CGPath;// 设置填充颜色为透明layer.fillColor = [UIColor clearColor].CGColor;// 使用POP动画_timer = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]];[_timer event:^{CGFloat value1 = arc4random()%100/100.f;POPSpringAnimation *strokeAnimationEnd = \[POPSpringAnimation animationWithPropertyNamed:kPOPShapeLayerStrokeEnd];strokeAnimationEnd.toValue = @(value1);strokeAnimationEnd.springBounciness = 12.f;[layer pop_addAnimation:strokeAnimationEnd forKey:@"layerStrokeAnimation"];} timeInterval:1*NSEC_PER_SEC];[_timer start];
}@end

[翻译] Shimmer相关推荐

  1. 《Real-Time Rendering 4th Edition》全文翻译 - 第5章 着色基础(中)5.3 ~ 5.4

    这两节终于翻译完毕,不得不说原文篇幅是真的长,花了不少时间. 另外,以后引用的具体文章标题不会再列出来,一是为了节省时间,二是感觉列出来会过于冗余.所以如果想看具体引用文章标题的话,请在原书里手动搜索 ...

  2. Mysql函数group_concat、find_in_set 多值分隔字符字段进行数据库字段值翻译

    Mysql函数group_concat.find_in_set进行数据库字段值翻译 场景 配方表:记录包含的原料 sources表示原料,字段值之间用逗号分隔 原料表:对应原料id和原料名称 现需要查 ...

  3. “Attention is All You Need 翻译

    <p><img src="output_0_0.png" alt="png"></p> "Attention is ...

  4. 基于PyTorch的Seq2Seq翻译模型详细注释介绍(一)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qysh123/article/deta ...

  5. 全文翻译(全文合集):TVM: An Automated End-to-End Optimizing Compiler for Deep Learning

    全文翻译(全文合集):TVM: An Automated End-to-End Optimizing Compiler for Deep Learning 摘要 人们越来越需要将机器学习应用到各种各样 ...

  6. 全文翻译(四) TVM An Automated End-to-End Optimizing Compiler

    全文翻译(四) TVM An Automated End-to-End Optimizing Compiler 6.3 嵌入式GPU评估 对于移动GPU实验,在配备ARM Mali-T860MP4 G ...

  7. 全文翻译(三) TVM An Automated End-to-End Optimizing Compiler

    全文翻译(三) TVM An Automated End-to-End Optimizing Compiler 5. 自动化优化 考虑到一组丰富的调度原语,剩下的问题是为DL模型的每一层,找到最佳的算 ...

  8. 全文翻译(二): TVM: An Automated End-to-End Optimizing Compiler for Deep Learning

    全文翻译(二): TVM: An Automated End-to-End Optimizing Compiler for Deep Learning 3.优化计算图 计算图是在DL框架中表示程序的常 ...

  9. 全文翻译(一):TVM: An Automated End-to-End Optimizing Compiler for Deep Learning

    全文翻译(一):TVM: An Automated End-to-End Optimizing Compiler for Deep Learning 摘要 人们越来越需要将机器学习应用到各种各样的硬件 ...

最新文章

  1. nx set 怎么实现的原子性_基于Redis的分布式锁实现
  2. Juniper批量新增用户命令工具
  3. Storm配置文件中主要参数配置说明
  4. 【大会】中低端机如何实现复杂多媒体功能?
  5. [AHOI2004]数字迷阵 结论+矩乘
  6. Android 系统(125)---Android通过Dialer实现暗码启动
  7. mysql里有sqlfront_使用SQL-Front启动MySQL8.0报错
  8. 超炫的3D特效程序管理功能android
  9. dropify插件的字符串
  10. How fast is a C++ extension by the PHP-CPP liberary?
  11. 长江课堂作业答案_长江作业本答案
  12. 新闻发布系统(java实现)+论文
  13. android 仿小米商城,仿小米商城网页版(全套)
  14. chm格式电子书另类反编译法:使用压缩软件7Z简单实现CHM电子书反编译 | 志文工作室
  15. Spring系列之@ComponentScan、@ComponentScans详解(bean批量注册)
  16. CAD随机多面体3D 多面体骨料 凸多面体颗粒
  17. 数据结构-C语言-严蔚敏
  18. 线性电阻电路方程的建立方法
  19. [Java]观察者模式和中介者模式改造机场
  20. 【SeMask】Semantically Masked Transformers for Semantic Segmentation

热门文章

  1. python 爬虫 ,抓取所有豆瓣好友读的书,列出读过最多的书。(模拟loging豆瓣)...
  2. spark Intellij IDEA及eclipse开发环境搭建
  3. 【Linux 内核】进程管理 - 进程优先级 ② ( prio 调度优先级 | static_prio 静态优先级 | normal_prio 正常优先级 | rt_priority 实时优先级 )
  4. 【C 语言】一级指针 易犯错误 模型 ( 判定指针合法性 | 数组越界 | 不断修改指针变量值 | 函数中将栈内存数组返回 | 函数间接赋值形参操作 | 指针取值与自增操作 )
  5. 【Android 逆向】Android 权限 ( adb 降权相关的属性 | ro.secure 属性 | ro.debuggable 属性 | service.adb.root 属性 )
  6. 【开发环境】Windows 系统中使用 Makefile 构建脚本编译 C 程序 ( 下载并安装 TDM-GCC 编译器 | 配置环境变量 | 编译 Makefile 程序 )
  7. 【Android 异步操作】Handler 机制 ( MessageQueue 空闲任务 IdleHandler 机制 )
  8. 【组合数学】组合恒等式 ( 变下项求和 3 组合恒等式 | 变下项求和 4 组合恒等式 | 二项式定理 + 求导 证明组合恒等式 | 使用已知组合恒等式证明组合恒等式 )
  9. 【DBMS 数据库管理系统】OLTP 联机事务处理 与 OLAP 联机分析处理 ( 数据仓库 与 OLAP | OLAP 联机分析处理 | OLTP 与 OLAP 区别 )
  10. 【iOS 开发】Objective - C 面向对象 - 方法 | 成员变量 | 隐藏封装 | KVC | KVO | 初始化 | 多态