Latest 1.0.0
Homepage https://github.com/wsj2012/EasyLoadingShimmer
License MIT
Platforms ios 9.0, requires ARC
Authors

这是一个网络请求页面加载等待的的框架,目前饿了么、京东等都是用此动态效果,接入方便快捷。

Installation

CocoaPods

The easiest way of installing EasyLoadingShimmer is via CocoaPods.

pod 'EasyLoadingShimmer'

Old-fashioned way

  • Add EasyLoadingShimmer.swift to your project.

Usage

Effect gif:

EasyLoadingShimmer

Demo:

  • 普通View视图添加loading
// 普通view视图
    // 在需要展示loading的地方
    EasyLoadingShimmer.startCovering(for: view)
    // 在需要隐藏loading的地方
    EasyLoadingShimmer.stopCovering(for: view)
  • UITableView中添加loading
    // UITableView中使用Demo   
    /* 步骤:
    ①、设置全局变量numberOfSections、numberOfRows都为0
    ②、创建UITableView并注册cell
    ③、实现代理(使用步骤①中的变量)
    ④、在需要展示loading的地方执行如下startLoading方法。
    */

    lazy var tableView: UITableView = {
        let t = UITableView.init(frame: view.bounds, style: .plain)
        t.dataSource = self
        t.delegate = self
        t.estimatedRowHeight = 150
        t.rowHeight = 150
        t.register(CustomCell.self, forCellReuseIdentifier: "Cell1")
        return t
    }()

    var numberOfRows: Int =  0
    var numberOfSections: Int = 0

    override func viewDidAppear(_ animated: Bool) {
        // 传入注册cell的identifier,数组传几个就会在loading时显示几个cell,跟实际返回显示数据无关
        EasyLoadingShimmer.startCovering(for: tableView, with: ["Cell1", "Cell1", "Cell1", "Cell1", "Cell1"])
    }

    @objc func startLoading() {
        numberOfSections = 0
        numberOfRows = 0
        tableView.reloadData()
        EasyLoadingShimmer.startCovering(for: tableView, with: ["Cell1", "Cell1", "Cell1", "Cell1", "Cell1"])
    }

    @objc func stopLoading() {
        numberOfSections = 1
        numberOfRows = 10
        tableView.reloadData()
        EasyLoadingShimmer.stopCovering(for: tableView)
    }

If you have any questions, you can check the Demo.

License

EasyLoadingShimmer is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

If this code was helpful, I would love to hear from you.

Latest podspec

{
    "name": "EasyLoadingShimmer",
    "version": "1.0.0",
    "summary": "u8fd9u662fu4e00u4e2au7f51u7edcu8bf7u6c42u9875u9762u52a0u8f7du7b49u5f85u7684u7684u6846u67b6uff0cu76eeu524du997fu4e86u4e48u3001u4eacu4e1cu3001u7b80u4e66u7b49u90fdu662fu7528u6b64u52a8u6001u6548u679cuff0cu63a5u5165u65b9u4fbfu5febu6377u3002",
    "homepage": "https://github.com/wsj2012/EasyLoadingShimmer",
    "license": "MIT",
    "authors": {
        "wsj_2012": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wsj2012/EasyLoadingShimmer.git",
        "tag": "1.0.0"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Libs/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This