很多APP登录注册的输入框都是四周没有边框,只有下边框有一条线,比如微信等。但是xib中却没有这种样式,想要实现这种效果,我们可以自定义一个UITextField,实现drawRect方法。
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, SQDColor(231, 236, 239).CGColor);
CGContextFillRect(context, CGRectMake(0, CGRectGetHeight(self.frame) - 1, CGRectGetWidth(self.frame), 1));
}
效果图
