0

我正在使用这个库,MDCOutlinedTextField,SWIFT 5,XCODE 版本 13.1 (13A1030d)。

当我通过试飞或不运行 Xcode 运行应用程序时,我遇到了这些问题,但是当我通过 Xcode 运行时,它工作得非常好。我附上下面的问题截图。

图1 图 2

在第一张图片中,城市和密码占位符文本被破坏(在大多数情况下,只有最后两个单词没有显示),当我在文本字段中写一些东西时,地址标签文本被破坏,正如我们在第二张图片中看到的那样. 我不知道为什么会这样,我在下面附上了我的代码。

 lazy var addressTextField: MDCOutlinedTextField = {
        var textField = MDCOutlinedTextField()
        textField.label.text = "Address"
        textField.setNormalLabelColor( .textDisplayColor, for: .normal)
        //textField.font = UIFont.customRegular.withSize(18)
        textField.label.adjustsFontForContentSizeCategory = true
        textField.attributedPlaceholder = NSAttributedString(string: " Enter your address ", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
        textField.setOutlineColor(UIColor.textFieldOutlineNormalColor, for: .normal)
        textField.setOutlineColor(UIColor.textFieldOutlineEditColor, for: .editing)
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

   lazy var stateTextField: MDCOutlinedTextField = {
        var textField = MDCOutlinedTextField()
        textField.label.text = "State"
        textField.setNormalLabelColor( .textDisplayColor, for: .normal)
        textField.attributedPlaceholder = NSAttributedString(string: "Select your state ", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
        textField.setOutlineColor(UIColor.textFieldOutlineNormalColor, for: .normal)
        textField.setOutlineColor(UIColor.textFieldOutlineEditColor, for: .editing)
        textField.trailingView = UIImageView(image: UIImage(named: "drop_down_icon"))
        textField.trailingViewMode = .always
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

    lazy var cityTextField: MDCOutlinedTextField = {
        var textField = MDCOutlinedTextField()
        textField.label.text = "City"
        textField.setNormalLabelColor(.textDisplayColor, for: .normal)
        textField.attributedPlaceholder = NSAttributedString(string: "Select your city", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
        textField.setOutlineColor(UIColor.textFieldOutlineNormalColor, for: .normal)
        textField.setOutlineColor(UIColor.textFieldOutlineEditColor, for: .editing)
        textField.trailingView = UIImageView(image: UIImage(named: "drop_down_icon"))
        textField.trailingViewMode = .always
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

    lazy var pincodeTextField: MDCOutlinedTextField = {
        var textField = MDCOutlinedTextField()
        textField.label.text = "Pincode"
        textField.keyboardType = .numberPad
        textField.setNormalLabelColor( .textDisplayColor, for: .normal)
       // textField.font = UIFont.customRegular.withSize(18)
        textField.label.adjustsFontForContentSizeCategory = true
        textField.attributedPlaceholder = NSAttributedString(string: "Enter your pincode", attributes: [NSAttributedString.Key.foregroundColor : UIColor.placeHolderColor])
        textField.setOutlineColor(UIColor.textFieldOutlineNormalColor, for: .normal)
        textField.setOutlineColor(UIColor.textFieldOutlineEditColor, for: .editing)
        textField.translatesAutoresizingMaskIntoConstraints = false
        return textField
    }()

如果有人知道这个解决方案,请与我分享谢谢。

4

0 回答 0