Белая "внешняя граница" появляется после изменения цветов UITextField в UIAlertController - PullRequest
0 голосов
/ 01 июля 2018

После успешного изменения цветов моего UIAlertController я решил сделать то же самое для UITextField внутри того же UIAlertController. Тем не менее, вокруг UITextField появляется белая «внешняя граница», а цвет границы, который я установил, виден внутри этой «внешней границы».

Я хочу, чтобы эта белая "внешняя граница" была прозрачной / того же цвета, что и фон просмотра UIAlertController.

Мой текущий код:

addAlert.addTextField(configurationHandler: { (textField) -> Void in
            textField.placeholder = "ABC 123"
            textField.textAlignment = .left
            textField.backgroundColor = Theme.current.barColor
            textField.textColor = Theme.current.titleColor
            textField.attributedPlaceholder = NSAttributedString(string: "ABC 123", attributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 14, weight: .regular), NSAttributedStringKey.foregroundColor : Theme.current.subTitleColor])
            textField.layer.borderWidth = 1.0
            textField.layer.borderColor = Theme.current.subTitleColor.cgColor
            textField.layer.backgroundColor = Theme.current.barColor.cgColor
        })

Снимок экрана UIAlertController:

enter image description here

Заранее спасибо!

1 Ответ

0 голосов
/ 03 июля 2018

Я смог удалить белую "внешнюю границу", запустив этот код ПОСЛЕ оповещения:

for textField in addAlert.textFields! {
    let container = textField.superview
    let effectView = container?.superview?.subviews[0]

    if (effectView as? UIVisualEffectView) != nil {
        container?.backgroundColor = .clear
        effectView?.removeFromSuperview()
    }
}

Это быстрое преобразование ответа Рори на другой вопрос

...