How to Toast message in Swift?

后端 未结 22 1188
暖寄归人
暖寄归人 2020-12-22 19:18

Is there any way to Toast message in swift ?

I have tried in objective c but could not find solution in swift.

[self.view makeToast:@\"Account create         


        
22条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 19:38

    Swift 4.2 Very easy and super way

    let toastLabel = UILabel()
    
    toastLabel.lineBreakMode = .byWordWrapping
    toastLabel.numberOfLines = 0
    toastLabel.text = "Type your message you want to show in toast"
    toastLabel.sizeToFit()
    //MARK Resize the Label Frame
    toastLabel.frame = CGRect(x: toastLabel.frame.origin.x, y: toastLabel.frame.origin.y, width: toastLabel.frame.size.width + 40, height: toastLabel.frame.size.height + 40)
    self.view.addSubview(toastLabel)
    

提交回复
热议问题