Present your custom notices in the application window so the notice isn't lost after leaving the screen.
Example
First, set the NoticeWindow to be the window of the AppDelegate:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? = NoticeWindow(frame: UIScreen.main.bounds)
// Helper property to quickly access the NoticeWindow
static var noticeWindow: NoticeWindow? {
return (UIApplication.shared.delegate as? AppDelegate)?.window as? NoticeWindow
}
}
Second, present a Notice using the static var on AppDelegate:
AppDelegate.noticeWindow?.presentNotice(title: "Oops", message: "An error has occurred", style: .error)
The default error style can be customized by changing properties on the NoticeViewStyle struct. For example:
var style = NoticeViewStyle.error
style.backgroundColor = UIColor(red: 0.839, green: 0.345, blue: 0.227, alpha: 1.00)
style.rightImage = .close
AppDelegate.noticeWindow?.presentNotice(title: "Oops", message: "An error has occurred", style: style)
For more detailed examples, including how to use a custom view, see the Example project in this repository.
Installation
CocoaPods
NoticeWindow is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "NoticeWindow"
Swift Package Manager
NoticeWindow can also be installed using the Swift Package Manager. To install it, add a package to your project with the following URL:
https://github.com/Q42/NoticeWindow.git
Releases
- 0.9.0 - 2022-10-10 - Add Swift Package Manager support
- 0.8.0 - 2019-06-10 - Swift 5.1 update
- 0.7.0 - 2018-10-02 - Swift 4.2 support
- 0.6.1 - 2018-01-28 - Improved iPhone X support
- 0.6.0 - 2017-09-17 - Experimental iPhone X support
- 0.5.2 - 2017-02-09 - Fix AutoLayout warnings
- 0.5.1 - 2017-01-19 - CocoaPods release
- 0.5.0 - 2017-01-02 - Swift 3 support
- 0.4.0 - 2016-11-06 - Support more styling
- 0.1.1 - 2015-12-08 - Initial public release
- 0.0.0 - 2015-04-28 - Initial private version for project at Q42
License
NoticeWindow is available under the MIT license. See the LICENSE file for more info.