Ios 如何在swift 4中隐藏SexyTooltip?

Ios 如何在swift 4中隐藏SexyTooltip?,ios,swift,Ios,Swift,我正试图在我的swift项目中使用SexyTooltip。 我有以下代码: func showTooltip(prefix: Int?){ var description = "" description = setProductIconTitle(prefix: prefix) let myAttribute = [ NSAttributedStringKey.foregroundColor: UIColor.black, NSAttrib

我正试图在我的swift项目中使用SexyTooltip。 我有以下代码:

func showTooltip(prefix: Int?){
        var description = ""

        description = setProductIconTitle(prefix: prefix)

        let myAttribute = [ NSAttributedStringKey.foregroundColor: UIColor.black,  NSAttributedStringKey.backgroundColor: .white]
        let greetingsText = NSAttributedString(string: description, attributes: myAttribute)

        let greetingsTooltip = SexyTooltip(attributedString: greetingsText, sizedTo: view, withPadding: UIEdgeInsetsMake(10, 5, 10, 5), andMargin: UIEdgeInsetsMake(20, 20, 20, 20))
        greetingsTooltip?.dismiss(inTimeInterval: 2)
        view.addSubview(greetingsTooltip!)

        greetingsTooltip?.present(from: iconView1, in: view, withMargin: 10, animated: true)
    }
此代码工作正常。我希望在同一时刻只看到一个提示/工具提示。 单击另一个按钮后-必须隐藏所有以前的提示/工具提示

怎么做?

试试这个

func showTooltip(prefix: Int?){

    for toolView in view.subviews {
        if toolView is SexyTooltip {
            toolView.removeFromSuperview()
        }
    }
    var description = ""
    description = setProductIconTitle(prefix: prefix)
    let myAttribute = [ NSAttributedStringKey.foregroundColor: UIColor.black,  NSAttributedStringKey.backgroundColor: .white]
    let greetingsText = NSAttributedString(string: description, attributes: myAttribute)

    let greetingsTooltip = SexyTooltip(attributedString: greetingsText, sizedTo: view, withPadding: UIEdgeInsetsMake(10, 5, 10, 5), andMargin: UIEdgeInsetsMake(20, 20, 20, 20))
    greetingsTooltip?.dismiss(inTimeInterval: 2)
    view.addSubview(greetingsTooltip!)

    greetingsTooltip?.present(from: iconView1, in: view, withMargin: 10, animated: true)
}

在浏览了上关于“解雇”的部分后,我猜是
解雇
,或者您可以告诉我们
解雇时间间隔
选项有错误:让greetingsTooltip=SexyTooltip!-类型名称后应为成员名称或构造函数调用try updaed answer