gpt4 book ai didi

swift - 像 Reddit 应用程序一样创建保存/取消保存后确认模式?

转载 作者:行者123 更新时间:2023-11-30 11:43:03 25 4
gpt4 key购买 nike

创建像 Reddit 应用程序一样的小型弹出窗口/模式的最佳方法是什么(请参阅下面的图片链接)?我尝试过使用 UIAlertView 但它不是很可定制。任何帮助/指导将不胜感激!

Screenshot of Reddit app's save "Post Saved!" confirmation modal

最佳答案

尝试这样的事情

extension UIViewController
{
func showNotificationView(message : String)
{
//base View
let baseView = UIView(frame: CGRect(x: 20, y: self.view.frame.size.height-(self.view.frame.size.height*0.15), width: self.view.frame.size.width-40, height: self.view.frame.size.height*0.08))
baseView.backgroundColor = UIColor.gray
baseView.clipsToBounds=true
self.view.addSubview(baseView)

//Image View
let imageView = UIImageView(image: UIImage(named: "RM_3"))
imageView.clipsToBounds=true
imageView.frame = CGRect(x: 0, y: 0, width: baseView.frame.size.width*0.2, height: baseView.frame.size.height)
baseView.addSubview(imageView)

//Label
let textLabel = UILabel(frame: CGRect(x: baseView.frame.size.width*0.2+10, y: 0, width: baseView.frame.size.width, height: baseView.frame.size.height))
textLabel.textColor = UIColor.white
textLabel.backgroundColor = UIColor.clear
textLabel.textAlignment = .left;
textLabel.numberOfLines = 0
textLabel.font = UIFont(name: "Montserrat-Light", size: 12.0)
textLabel.text = message
baseView.addSubview(textLabel)
}
}

如何使用

 @IBAction func navigate(_ sender: Any) {
self.showNotificationView(message: "hihihihh")
}

输出

enter image description here

关于swift - 像 Reddit 应用程序一样创建保存/取消保存后确认模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com