Swift的本地通知横幅。
使用Cocoapods进行设置(推荐设置)
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'GTNotification', '>= 1.4'
然后在您的Swift类顶部添加import GTNotification
最后编译并运行,您就可以开始了。
否则,您还可以手动导入框架
只需将'GTNotification/*.swift
文件拖入您的Xcode项目,并确保勾选“如果需要则复制项”以及“添加到目标”部分中的相应的复选框。
示例
// Initialize a notification
let notification: GTNotification = GTNotification()
notification.title = "Welcome Notification"
notification.message = "Thank you for checking out GTNotificationView."
notification.position = GTNotificationPosition.Top
notification.animation = GTNotificationAnimation.Slide
notification.blurEnabled = true
// Perform a custom selector on tap
notification.addTarget(self, action: Selector("dismissNotification"))
// Set the notification's delegate
notification.delegate = self
// Show the notification
GTNotificationManager.sharedInstance.showNotification(notification)
GTNotification代理方法
// MARK: GTNotificationDelegate Methods
func notificationDidDismiss(notification: GTNotification)
{
// The notification was dismissed automatically
NSLog("The notification was dismissed automatically")
}
func notificationFontForTitleLabel(notification: GTNotification) -> UIFont
{
return UIFont(name: "AvenirNext-Medium", size: 16.0)!
}
func notificationFontForMessageLabel(notification: GTNotification) -> UIFont
{
return UIFont(name: "AvenirNext-Regular", size: 13.0)!
}
截图
暗模糊
明模糊
超亮模糊
纯色