Search code examples
iosswiftios8calayer

CALayer not showing iOS8


In a contact form for my app the text input fields have a white line across the bottom of the box.

let border = CALayer()
border.frame = CGRect(x: 0, y: textInput.frame.height, width: textInput.frame.width, height: 3)
border.borderColor = UIColor.white.cgColor
border.borderWidth = 3
textInput.layer.addSublayer(border)

The desired border shows up fine on iOS10 but when testing on iOS8 it doesn't show.

Is there some niche to iOS 8 that I am unaware of?


Solution

  • Your Y point is height of the textinput make it 0 or something less than height

    let border = CALayer()
    
    border.frame = CGRect(x: 0, y: textInput.frame.height - 3, width: textInput.frame.width, height: 3)
    
    border.borderColor = UIColor.white.cgColor
    
    border.borderWidth = 3
    
    textInput.layer.addSublayer(border)