Home>

If i set a custom class for UITextfield, the simulator will freeze on the actual machine.
I am processing to put underline in UIText filed.

Is it okay to apply a custom class to UITextFiled? ..

import UIKit
class CustomTextField: UITextField {

    let underline: UIView = UIView()
    override func layoutSubviews() {
        super.layoutSubviews()
        self.frame.size.height = 50
        composeUnderline()
    }
    private func composeUnderline() {
        self.underline.frame = CGRect(
            x: 0,
            y: self.frame.height,
            width: self.frame.width,
            height: 1.5)
        self.underline.backgroundColor = UIColor(red: 0.97, green: 0.59, blue: 0.32, alpha: 1.00)

        self.addSubview(self.underline)
        self.bringSubviewToFront(self.underline)
    }
}
  • Answer # 1

    Thank you for your comment.
    Solved in another way. ..