UITextField Only Top And Bottom Border

后端 未结 11 995
温柔的废话
温柔的废话 2020-12-07 22:46

I currently have a regular border. I would like to only have a top and bottom border.

How do I accomplish this?

Using the UITextField<

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 23:40

    One approach I have found works good is using layers. Here's a snippet:

    CALayer *bottomBorder = [CALayer layer];
    bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.frame.size.width, 1.0f);
    bottomBorder.backgroundColor = [UIColor blackColor].CGColor;
    [myTextField.layer addSublayer:bottomBorder];
    

    Hope this helps someone.

提交回复
热议问题