'Uitextfieldwith dashed line, focus, default dashed color lines in swift
I haven given spaces between chars with NSattributes.kern, need to change focus color of next char border when text enter, should be do with one textfield
class customTextFiled : UITextField {
for index in 0...charCount {
let customBorder = CALayer()
customBorder.frame = CGRect(x: 0, y: frame.height-2, width: 30, height : 10)
customBorder.borderColor = .green
layer .insertSublayer(customBorder, at: UInt32(index))
}
}
textDidChange() {
// get char count ex 4
layer.sublayers.first[4].backgroundColor = black
layer.sublayers.first[3].backgroundColor = clear
}
}
when changing the next index layer example 2 layer color black,clearing previous layer example 1 index color, but still 1 index layer showingthin line green(this is default color when created the layer)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|