Код: Выделить всё
private var secureTextField: UITextField?
private func initTextField() {
let boundLength = max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
secureTextField = UITextField(frame: CGRect(x: 0, y: 0, width: boundLength, height: boundLength))
secureTextField!.isSecureTextEntry = true
secureTextField!.isUserInteractionEnabled = false
secureTextField!.backgroundColor = .red
if let rootView = UIApplication.shared.keyWindow?.rootViewController?.view {
for subview in rootView.subviews {
subview.addSubview(secureTextField!)
subview.layer.superlayer?.addSublayer(secureTextField!.layer)
secureTextField!.layer.sublayers?.last?.addSublayer(subview.layer)
}
}
}
На некоторых экранах я хочу отключить это и разрешить снимки экрана, но не понял, как это сделать. Как я могу отменить/удалить UITextField во всех подслоях/подпредставлениях?
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/790 ... -sublayers
Мобильная версия