• [翻译] 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.

  • 相关阅读:
    1.Math函数对象
    1.日期与时间
    使用object literal替换switch
    Array数组去重
    flexbox弹性布局
    web移动端一些常用知识
    解决网页ICON图标无法显示的问题
    观察者模式和发布订阅模式的区别
    JS延迟加载的几种方式
    前端 api 请求缓存方案
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4418431.html
Copyright © 2020-2023  润新知