【问题标题】:Creating save/unsave post confirmation modal like in Reddit app?在 Reddit 应用程序中创建保存/取消保存后确认模式?
【发布时间】:2018-03-06 05:24:37
【问题描述】:

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

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

【问题讨论】:

  • 我的解决方案是否有效或需要更多修改?如果您已完成此问题所需的步骤,请关闭此线程

标签: swift


【解决方案1】:

试试这样的

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")
    }

输出

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    相关资源
    最近更新 更多