Today almost all apps have Api requests. Despite the fact that many of them fail dure to network issue or for any other reasons.NRView
has been conceived to address this need, an elegant message to users with a minimal effort.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Ability to show image, text, button or all of them.
- Add pre-customized attributes for the element.
- Handle button action if needed.
iOS 10.0+ Xcode 10.2+ Swift 5+
Example 01 | Example 02 | UICollectionViewCell | UITableViewCell |
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate NRView into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'NRView', '~> 0.2.0'
If you prefer not to use any of the aforementioned dependency managers, you can copy Source
into your project manually.
- Drag
View
object from the Object Library into your storyboard.
- Set the view's class to
NRView
in the Identity Inspector.
- Customize the
NRView
appearance in the Attributes Inspector.
Add import NRView
to your source code.
Setup NRViewSettings
object
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
}()
Initialize NRView with settings
lazy var nrView: NRView = {
let nrView = NRView.addToView(view, settings: settings)
// Action when button tapped
nrView.didTapButton = { button in
print("Button Tapped...")
}
return nrView
}()
Show & hide NRView
with different animations types.
nrView.show(withAnimationType: .fade(0.5))
nrView.hide(withAnimationType: .none)
- If you found a bug, open an issue here on GitHub and follow the guide. The more detail the better!
- If you want to contribute, submit a pull request.
NRView
is licensed under the MIT license. The icons are made by Freepik from Flaticon and are licensed under Creative Commons BY 3.0.