Energy Bar is very simple message bar that get to user's response.
pod 'EnergyBar'
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let energyBar = EnergyBar(delegate: self)
return true
}
}
extension AppDelegate: EnergyBarDelegate {
func buttonTap(eventID: String, tag: Int) {
//handle your event
}
}
try? energyBar.show(eventID:messageLabel:buttons:size:)
energyBar.bringEnergyBarToFront()
- Make
energyBar
singleton likeApp.energyBar
AppDelegate
class must haveEnergyBarDelegate
- Make custom events use
enum
like...and... pass enum's rawValue toenum EnergyBarEvents: String { case doSomething = "doSomethingEvent" }
show
method like...theneventID: EnergyBarEvents.doSomething.rawValue
EnergyBarDelegate
returns eventID. and handle event like...if let event = EnergyBarEvents(rawValue: eventID) { switch event { case .doSomething: //handle event } }