How to change the size of blinking bar/line for specific UITextField?

前端 未结 3 1658
走了就别回头了
走了就别回头了 2021-01-14 02:10


i\'m working on a project(Swift4,Xcode 9.2) which has a feature to get text input and the blinking bar/line should be of big size (it should be S

3条回答
  •  攒了一身酷
    2021-01-14 03:00

    There are some unnecessary lines of codes, so this is the revised:

    class CustomTextField: UITextField {
        override func caretRect(for position: UITextPosition) -> CGRect {
            var rect = super.caretRect(for: position)
            rect = CGRect(x: rect.origin.x, y: .zero, width: 15, height: 30)
            return rect
        }
    }
    

提交回复
热议问题