OGeek|极客世界-中国程序员成长平台

标题: ios - 添加将包含输入的 UIView [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:42
标题: ios - 添加将包含输入的 UIView

所以基本上我有我创建的这个页面控制 View ,有人会在点击登录或注册按钮时进入。因此,当它转到该页面 View 时,我尝试在该页面上设置 UIView,以便用户可以输入所需的信息。

下面的代码是我实现它的方式。请注意,此功能是注册按钮的目标。所以即使运行这个没有框出现?有什么见解吗?

 func regSegue() {
    let page = UIPageViewController()
    page.view.backgroundColor = UIColor .white; //Set to any color.
    present(page, animated: true, completion: nil)

 // will create an inputs container view so users can enter credentials to register

    let regContainerView = U
    regContainerView.backgroundColor = UIColor.red

    regContainerView.translatesAutoresizingMaskIntoConstraints = false
    present(regContainerView, animated: true, completion: nil)

//need x,y,width, and height

    regContainerView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

     regContainerView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true

    regContainerView.widthAnchor.constraint(equalTo: view.widthAnchor, constant: -24).isActive = true

    regContainerView.heightAnchor.constraint(equalToConstant: 150).isActive = true

}



Best Answer-推荐答案


var txtField: UITextField = UITextField(frame: CGRect(x: 0, y: 0, width: 500.00, height: 30.00));

self.view.addSubview(txtField)

这就是您如何将一个添加到您的 View .. 只是一个例子。 希望你能有一个想法并按照自己的方式去做。

关于ios - 添加将包含输入的 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44075394/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4