[翻译] Shimmer

简介:

Shimmer

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可以让你非常容易的添加闪光效果到你的app当中,尤其是在加载的时候使用,非常有用.

Shimmer最初是在 Paper 应用中是使用的效果.

Shimmer

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属性设置成YES.

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 open FBShimmering.xcworkpace rather than the .xcodeproj.)

Installation

There are two options:

有两种安装方式:

  1. Shimmer is available as Shimmer in Cocoapods. 使用Cocoapods安装
  2. Manually add the files into your Xcode project. Slightly simpler, but updates are also manual. 直接将项目源码拖到你的项目当中.

Shimmer requires iOS 6 or later.

Shimmer 需要iOS6或者以上版本.

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]属性来制造闪光效果.

Other Platforms

We have a version of Shimmer for Android, too! It's also available on GitHub.

Contributing

See the CONTRIBUTING file for how to help out.

License

Shimmer is BSD-licensed. We also provide an additional patent grant.

目录
相关文章
|
数据采集 量子技术 双11
【2023 年第十三届 MathorCup 高校数学建模挑战赛】C 题 电商物流网络包裹应急调运与结构优化问题 建模方案及代码实现
本文提供了2023年第十三届MathorCup高校数学建模挑战赛C题的详细建模方案及代码实现,针对电商物流网络中的包裹应急调运与结构优化问题,提出了包括时间序列分析在内的多种数学模型,并探讨了物流网络的鲁棒性。
216 2
【2023 年第十三届 MathorCup 高校数学建模挑战赛】C 题 电商物流网络包裹应急调运与结构优化问题 建模方案及代码实现
|
机器学习/深度学习 人工智能 算法
深度学习基础:从零开始的入门课
【8月更文挑战第21天】通过本文,我们简要介绍了深度学习的基本概念、基础框架以及入门实践。然而,深度学习是一个博大精深的领域,需要不断的学习和实践才能掌握其精髓。建议你在学习过程中,结合具体项目,通过解决实际问题来加深对理论知识的理解。同时,关注最新的研究成果和技术动态,保持对新技术的好奇心和学习热情,相信你会在深度学习的道路上越走越远。
|
9月前
|
缓存 API 开发工具
Qwen-coder方向-如果从0开始应用通义千问开源大模型
从0开始接触,带您全面了解Qwen2.5语言模型家族,包括其核心功能、微调方法以及具体应用场景。我们将通过一系列精心准备的应用demo和使用指南,帮助您掌握如何充分利用Qwen2.5的强大能力
1103 8
|
存储 监控 安全
网络安全法中的 ISO 27001 和 CIA
【8月更文挑战第19天】
560 0
|
机器学习/深度学习 人工智能 自然语言处理
AI对日常生活的影响
AI对日常生活的影响
374 2
|
机器学习/深度学习 监控 算法
人脸跟踪:基于人脸检测 API 的连续检测与姿态估计技术
基于人脸检测 API 的人脸跟踪技术在视频监控、虚拟现实和人机交互等领域具有广泛应用。通过连续的人脸检测与姿态估计,可以实现对人脸的跟踪和姿态分析。随着深度学习和计算机视觉技术的不断发展,人脸跟踪技术将迎来更加精确、实时和智能化的发展前景
446 0
|
SQL 固态存储 关系型数据库
|
运维 供应链 监控
韵达基于云原生的业务中台建设 | 实战派
本文将为大家分享韵达业务中台基于云原生的建设过程。主要分为三部分,第一部分是 IT 信息的发展规划,第二部分是韵达业务中台建设的详细过程,第三部分是对应云原生技术的支撑。
韵达基于云原生的业务中台建设 | 实战派
|
Android开发
Android 音乐APP(六)Activity和Notification通讯
Android 音乐APP(六)Activity和Notification通讯
419 0
Android 音乐APP(六)Activity和Notification通讯
|
Python
Python编程:将Flask项目部署到免费服务器Heroku
Python编程:将Flask项目部署到免费服务器Heroku
574 0
Python编程:将Flask项目部署到免费服务器Heroku