美文网首页
Swift 简单的弹框提示

Swift 简单的弹框提示

作者: novice_Qin | 来源:发表于2018-06-05 17:05 被阅读0次

    这是一个简单,易用,代码比较少的swift弹框提示,能根据文本高度,自行调整位置和弹框高度

    1.0

    没有点击按钮时候没有显示的弹框

    1.1

    点击按钮出现一个提示弹框

    1.2

    具体代码如下:

    let titleLabel = UILabel()

                    titleLabel.text = languageStr("Login successful")

                    titleLabel.backgroundColor = titleutColor

                    titleLabel.font = UIFont.systemFont(ofSize: 17)

                    titleLabel.textAlignment = NSTextAlignment.center

                    titleLabel.textColor = UIColor.white

                    titleLabel.layer.cornerRadius = 5

                    titleLabel.layer.masksToBounds = true

                    titleLabel.numberOfLines = 0

                    titleLabel.frame = CGRect.init(x: KScreenWidth * 0.24, y: KScreenHeight * 0.73, width: KScreenWidth * 0.6, height: KScreenHeight * 0.05)

                    UIView.animate(withDuration: 0.5, animations: {

                        self.view.addSubview(titleLabel)

                    },  completion: {(b:Bool) -> Void in

                        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {//弹出以后一秒后自行消失

                            titleLabel.removeFromSuperview()

                            weakSelf?.showAllCureenView()

                        }

                    })

    新手一枚刚开始写简书文章,不喜勿喷。欢迎大牛来指导技术 Q1255130032

    相关文章

      网友评论

          本文标题:Swift 简单的弹框提示

          本文链接:https://www.haomeiwen.com/subject/aehmsftx.html