提示框SwiftMessage的安装与使用

安装

1.Xcode中,点击Project页面下方的+号(Add Package Dependency)

2.右上角搜索栏输入网址 https://github.com/SwiftKickMobile/SwiftMessages 点击Add Package即可安装

使用

1.在工程开头导入SwiftMessage

import SwiftMessages

 2.创建一个function以调用SwiftMessage

title:标题

body:内容

iconText:文本构成的Emoji

func pop(){
        AudioServicesPlaySystemSound(1519)
        let view = MessageView.viewFromNib(layout: .cardView)

        // Theme message elements with the warning style.
        view.configureTheme(.info)

        // Add a drop shadow.
        view.configureDropShadow()

        // Set message title, body, and icon. Here, we're overriding the default warning
        // image with an emoji character.
       
        //隐藏按钮
        view.button?.isHidden = true
        
        let iconText = ["✔️"].randomElement()!
        
        view.configureContent(title: "收到!", body: "添加完成", iconImage: .none, iconText: iconText, buttonImage: UIImage(systemName:"checkmark"), buttonTitle: .none, buttonTapHandler: .none)
        

        // Increase the external margin around the card. In general, the effect of this setting
        // depends on how the given layout is constrained to the layout margins.
        view.layoutMarginAdditions = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)

        // Reduce the corner radius (applicable to layouts featuring rounded corners).
        (view.backgroundView as? CornerRoundingView)?.cornerRadius = 10

        // Show the message.
        SwiftMessages.show(view: view)
        
    }

3.在需要的地方调用即可

pop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值