To run the example project, clone the repo, and run pod install
from the Example directory first.
iStatusView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'iStatusView'
StatusView.appearance().titleLabelTextColor = UIColor.black
StatusView.appearance().titleLabelFont = UIFont.boldSystemFont(ofSize: 18)
StatusView.appearance().messageLabelTextColor = UIColor(white: 0.2, alpha: 1.0)
StatusView.appearance().messageLabelFont = UIFont.systemFont(ofSize: 16)
StatusView.appearance().backgroundColor = UIColor.white
Feel free to add in any loading indicator you fancy
An example using the UIActivityIndicator
let loadingView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.whiteLarge)
loadingView.color = UIColor.black
loadingView.startAnimating()
loadingView.bounds = CGRect(x: 0, y: 0, width: 80, height: 80)
Use the convenient create function, you must pass a loading view (even if its just a blank UIView, else nothing will work)
self.statusView = StatusView.create(with: loadingView, addTo: self.view)
Set the size, in this case we are using SnapKit to set the AutoLayout constraints to fill the whole view. Can also use AutoResizingMasks, StoryBoard or other declarative AutoLayout code
self.statusView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
A button appears when a button image is set when setting the state Useful for a retry button, or cancel loading button
self.statusView.button.addTarget(self, action: #selector(statusViewButtonPressed), for: .touchUpInside)
state
: what state the status view is in. loading
will show the loading indicator, message
will hide the loading indicator, hidden
will hide the whole status view.
title
: optional; is the main title of the status.
message
: optional; is the more detailed message to be displayed.
statusImage
: optional; shows an image to be displayed
buttonImage
: optional; when an image is set, it will show as a pressable button
try? self.statusView.changeTo(
state: .loading,
title: "Title of status",
message: "More info on the status",
statusImage: nil,
buttonImage: nil,
animate: false)
From here set the state to .hidden or to .message depending on the state of loading the content
iStatusView is available under the Apache license. See the LICENSE file for more info.