CRNetworkButton 版本 1.0.2

CRNetworkButton 版本 1.0.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016年11月
SwiftSwift 版本3.0
SPM支持 SPM

Denisenko Vladislav 维护。




CRNetworkButton 版本 1.0.2

  • Cleveroad

CRNetworkButton Awesome

Header image

欢迎使用 CRNetworkButton - 高级按钮点击交互

这是 Cleveroad 提供的新 iOS 库。如果您已经厌倦了移动应用中普通的按钮点击,我们可以提供一些新的和独特的功能。现在,当用户点击涉及到服务器操作的按钮时,他们会看到动画,告知他们进度和完成情况。这种新的引人入胜的按钮点击交互是由 CRNetworkButton 库实现的。

Demo image

如果您希望通过按钮向您的应用程序用户提供明确的信息,那么欢迎您将 CRNetworkButton 库集成到您的 iOS 应用程序中。简化用户与您的应用程序的交互!

Awesome

要求

  • iOS 8 或更高版本

安装

CRNetworkButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod "CRNetworkButton"

然后在终端中运行 pod install

import CRNetworkButton

设置

CLNetworkButton 利用 IB的所有优势,具备@IBInspectable和@IBDesignable的特性。所有必要的自定义属性均作为@IBInspectable声明,以便您可以直接从Storyboard中设置它。此外,CLNetworkButton为所有属性提供了默认值,因此您只需将其拖放到视图中,即可轻松实现网络活动按钮。

使用方法

  • 支持Storyboard;
  • 设置StartTextEndText,它们将在动画前后显示,您还可以设置错误状态下的文本,该文本将作为标题显示,当调用stopByError()时默认文本为“错误”。
  • shouldAutoreverse设置为true,自动在起始状态返回。
  • animateOnTap设置为true(默认为true),允许您在触摸操作内部自动触发动画机制然后使用它或将它手动使用。

    @IBAction func buttonTapped(sender: CRNetworkButton) {
        sender.startAnimate()
    }
  • progressMode设置为true,并使用updateProgress(progress: CGFloat)更新当前进度。

    func downloadProgress(progress: CGFloat) {
        networkButton.updateProgress( progress )
    }
  • 要停止动画,请调用stopAnimate()。如果流程以错误结束,请调用stopByError()。这将导致动画以错误风格停止。

    @IBAction func buttonTapped(sender: CRNetworkButton) {
        SomeNetworkManager.performRequest(withSuccess: { (result) in
            sender.stopAnimate()
        }) { (error) in
            sender.stopByError()
        }
    }


示例

要运行示例项目,请先克隆存储库,然后从示例目录运行pod install

支持

如果您有关于此库使用的其他任何问题,请通过[email protected]与我们联系以获取支持(邮件主题:“CRNetworkButton. 支持请求。”)


许可证


The MIT License (MIT)

Copyright (c) 2016 Cleveroad Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.