SCPromptView-Swift

SCPromptView

SCPromptView: 顯示在頂部的提示控件
OC版

你的star是我最大的動(dòng)力

effect.gif

安裝

手動(dòng)安裝

下載源碼,將SCPromptView文件夾拖進(jìn)項(xiàng)目

CocoaPod

pod 'SCPromptView'

使用

SCPromptView 的用法,與tableView相似

創(chuàng)建view

class TestView: SCPromptView {
    var label:UILabel?
    
    override func sc_setUpCustomSubViews() {
        backgroundColor = UIColor.clear
        contentView.backgroundColor = UIColor.init(red:CGFloat(arc4random()%255)*1.0/255, green: CGFloat(arc4random()%255)*1.0/255, blue: CGFloat(arc4random()%255)*1.0/255, alpha:1)
        contentView.layer.cornerRadius = 10
        contentView.layer.masksToBounds = true
        label = UILabel(frame: contentView.bounds)
        label?.textColor = UIColor.white
        label?.textAlignment = NSTextAlignment.center
        contentView.addSubview(label!)
    }
    override func sc_loadParam(param: Any?) {
        if param != nil {
        let text = param as! String
        label?.text = text
        }else{
            label?.text = ""
        }
    }
}

重寫兩個(gè)基礎(chǔ)方法

注冊

sc_prompt_register(viewClass:TestView.classForCoder(), showCommand: "test")

發(fā)送顯示命令

///隨機(jī)顏色顯示
func clickBtn(){
        let str:String = "\(num)"
        sc_prompt_show(showCommand: "test", param: str)
        num += 1
    }

其他Api

    ///高度
    func sc_height() -> CGFloat {
    }
    ///滑動(dòng)距離
    func sc_slideDistanse() -> CGFloat {
    }
    ///顯示時(shí)間
    func sc_showTime() -> TimeInterval {
      
    }
    ///出現(xiàn)動(dòng)畫時(shí)間
    func sc_showAnimationDuration() -> TimeInterval {
        
    }
    ///隱藏動(dòng)畫時(shí)間
    func sc_hideAnimationDuration() -> TimeInterval {
        
    }

必須重寫的方法

 //MARK: load
    ///設(shè)置子控件
    func sc_setUpCustomSubViews(){
        
    }
    func sc_loadParam(param:Any?){
        
    }

SCPromptView

SCPromptView : A prompt view which show in the top of the screen .

Your star is my biggest motivation.

Install

Manually

Download the source code , copy folder SCPromptView into your project.

CocoaPod

pod 'SCPromptView'

Usage

The usage of SCPromptView is similar to the usage of UITableView.

Create Custom View

class TestView: SCPromptView {
    var label:UILabel?
    
    override func sc_setUpCustomSubViews() {
        backgroundColor = UIColor.clear
        contentView.backgroundColor = UIColor.init(red:CGFloat(arc4random()%255)*1.0/255, green: CGFloat(arc4random()%255)*1.0/255, blue: CGFloat(arc4random()%255)*1.0/255, alpha:1)
        contentView.layer.cornerRadius = 10
        contentView.layer.masksToBounds = true
        label = UILabel(frame: contentView.bounds)
        label?.textColor = UIColor.white
        label?.textAlignment = NSTextAlignment.center
        contentView.addSubview(label!)
    }
    override func sc_loadParam(param: Any?) {
        if param != nil {
        let text = param as! String
        label?.text = text
        }else{
            label?.text = ""
        }
    }
}

Override two basic function.

Register

sc_prompt_register(viewClass:TestView.classForCoder(), showCommand: "test")

Show

///show random color
///隨機(jī)顏色顯示
func clickBtn(){
        let str:String = "\(num)"
        sc_prompt_show(showCommand: "test", param: str)
        num += 1
    }

Other Api

   ///高度
    func sc_height() -> CGFloat {
    }
    ///滑動(dòng)距離
    func sc_slideDistanse() -> CGFloat {
    }
    ///顯示時(shí)間
    func sc_showTime() -> TimeInterval {
      
    }
    ///出現(xiàn)動(dòng)畫時(shí)間
    func sc_showAnimationDuration() -> TimeInterval {
        
    }
    ///隱藏動(dòng)畫時(shí)間
    func sc_hideAnimationDuration() -> TimeInterval {
        
    }

MUST OVERRIDE

 //MARK: load
    ///設(shè)置子控件
    func sc_setUpCustomSubViews(){
        
    }
    func sc_loadParam(param:Any?){
        
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容