How do I create connected text fields in ios?

2019-08-14 04:40发布

问题:

I want to create a login screen similar to facebook's for my iOS app.

How do I create 2 text-fields that are both in that rounded box?

回答1:

Embed two textfields in a UIView and give that view the layer.cornerRadius that you need

Giving UIView rounded corners



回答2:

  1. add 2 UITextfields and set their borders to none
  2. add background image having rounded corner from top left and top right to the 1st uitextfield i.e. username uitextfield
  3. add background image having rounded corner from bottom left and bottom right to the 2nd uitextfield i.e. password uitextfield
  4. add a bordered layer (CALayer), set layer properties like, borderwidth, borderColor and frame as per your requirement and add this layer to uitextfield layer.