mfNotification 1.0.4

mfNotification 1.0.4

Mohammad Firouzi 维护。



  • Mohammad Firouzi

mfNotification

Version License Platform

描述

mfNotification 是一个内置通知视图,允许您在应用的任何地方轻松显示通知。

安装

mfNotification 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'mfNotification'

使用

import UIKit
import mfNotification

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func simulatePressed(_ sender: Any) {
        let notification = mfNotification()
        notification.present(title: "Title", text: "This is Text")
    }
}

它还可以用于添加代理并进一步以这种方式自定义

import UIKit
import mfNotification

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func simulatePressed(_ sender: Any) {
        let notification = mfNotification()
        
        //set attributes
        var myAttributes = mfNotificationAttributes()
        myAttributes.textColor = .black //and other attributes ...
        notification.attributes = myAttributes
        
        //set delegate
        notification.delegate = self
        
        //set custom duration
        notification.duration = 4.0
        
        //turn on/off soundAlert
        notification.soundAlert = true
        
        //present notification
        notification.present(title: "Title", text: "This is Text", avatar: UIImage(named: "Image"), info: "This is info")
    }
}

extension ViewController: mfNotificationDelegate {
    func mfNotificationClicked(info: Any?) {
        print(info)
    }
    
    func mfNotificationWillDismiss() {
        
    }
    
    func mfNotificationDidDismiss() {
        
    }
}

作者

Mohammad Firouzi, [email protected]

许可协议

mfNotification受MIT协议许可。更多详情请查阅LICENSE文件。