0

I am very new to IOS Xcode. I am building a login page in that I want the textField should show only the border-bottom and the storyboard should have a custom gradient background color. I referred many websites but I am not getting proper results. How to get it, please Help!

Sneha Patil
  • 67
  • 1
  • 9
  • We don't know how your app is set up etc. It's only possible to give general answers that might be totally not applicable in your case. So please add some code and read the [Asking a question help](https://stackoverflow.com/help/how-to-ask). Edit: Maybe [this SO thread](https://stackoverflow.com/questions/26800963/uitextfield-border-for-bottom-side-only-in-swift) might help you anyway. – Akaino Jan 18 '18 at 08:48
  • possible duplicate https://stackoverflow.com/q/26800963/5567142 – Alok Subedi Jan 18 '18 at 08:54
  • Please follow this link : https://stackoverflow.com/questions/26800963/uitextfield-border-for-bottom-side-only-in-swift – Sarabjit Singh Jan 18 '18 at 09:04
  • hi Akaino, I am a javascript developer and I am not familiar with IOS. In my application, I have created a sample login page with username and password in Xcode. I am done with designing part but I don't have any idea about the coding part. Please let me know how to proceed further. – Sneha Patil Jan 18 '18 at 09:52

2 Answers2

2

Here is the Answer , you can add the layer into your textField. Just use the below code.

in below code , txtField means your textField in which you want to add the border.

let borderLayer = CALayer()
borderLayer.backgroundColor = color.cgColor

// origin y should be height - 1
borderLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: (txtField.frame.size.height - 1), size: CGSize(width: txtField.frame.size.width, height: 1.0))

txtField.layer.addSublayer(borderLayer)
7wind_c
  • 3
  • 5
Er.Gopal Vasani
  • 448
  • 3
  • 12
0

You may put a view under the textfeild with height of 1 and leading,trailingand bottom hooked to the textfeild

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87