NRView 0.2.2

NRView 0.2.2

Ahmed M. Hassan维护。



NRView 0.2.2

  • Ahmed M. Hassan

NRView

Pod Version Pod Platform Pod License CocoaPods compatible

今天几乎所有的应用都进行 API 请求。尽管许多请求因网络问题或其他原因而失败。《NRView》被设计用来解决这一需求,以最小的努力为用户提供优雅的消息。

入门

以下说明将帮助您在本地计算机上获得项目副本并运行,以便进行开发和测试。有关如何在实时系统中部署项目,请参阅部署部分。

功能

  • 能够显示图片、文本、按钮或它们的组合。
  • 为元素添加预定义属性。
  • 如有需要,处理按钮动作。

要求

iOS 10.0+ Xcode 10.2+ Swift 5+

预览

示例 01 示例 02 UICollectionViewCell UITableViewCell

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。有关使用和安装说明,请访问他们的网站。要使用 CocoaPods 将 NRView 集成到您的 Xcode 项目中,请在 Podfile 中指定它。

pod 'NRView', '~> 0.2.0'

手动

如果您不希望使用所提到的任何依赖管理器,您可以手动将 Source 复制到您的项目中。

工作原理

使用 Storyboard/xib

  1. View 对象从 对象库 拖到您的 storyboard 中。

Add view control in attributes inspector

  1. 身份检查器 中将视图的类设置为 NRView

Add Cosmos rating view to the storyboard

  1. 属性检查器 中自定义 NRView 的外观。

Add Cosmos rating view to the storyboard

编程方式

import NRView 添加到您的源代码中。

设置 NRViewSettings 对象

  let settings: NRSettings = {
    var settings = NRSettings()
    
    // Set title label text
    settings.titleText = "Unable to Connect"
    
    // Set subtitle label text
    settings.subtitleText = "Please check your internet connection and try again."
    
    // Set image 
    settings.image = UIImage(named: "group")
    
    // Set image tint color
    settings.imageColor = .gray
    
    // Image width, types available are regular, compact or set any width  
    settings.imageWidthType = .compact
    
    // Set button configuration 
    var buttonSettings = NRButtonSettings()
    
    // Button title
    buttonSettings.title = "Try Again"
    
    // Button corner radius
    buttonSettings.cornerRadius = 3
    
    // Button background color
    buttonSettings.backgroundColor = UIColor.blue.withAlphaComponent(0.1)
    
    // Button text color
    buttonSettings.textColor = .blue
    
    // Button settings, set to nil to hide the button
    settings.buttonSettings = buttonSettings
    
    return settings
  }()

用设置初始化 NRView

  lazy var nrView: NRView = {
    let nrView = NRView.addToView(view, settings: settings)
    
    // Action when button tapped
    nrView.didTapButton = { button in
      print("Button Tapped...")
    }
    return nrView
  }()

显示和隐藏 NRView,使用不同的动画类型。

nrView.show(withAnimationType: .fade(0.5))
nrView.hide(withAnimationType: .none)

通信

  • 如果您发现了一个错误,请在此GitHub上提交一个问题,并遵循指南。信息越详细越好!
  • 如果您想要贡献,请提交一个pull request。

许可证

《NRView》项目许可证为MIT协议。图标由Freepik制作,来自Flaticon,并授权于Creative Commons BY 3.0协议。