Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bottom Border in UiTextfield

Actually i have created Border in Textfiled by using this code.

 CALayer *bottomBorder = [CALayer layer];

bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.layer.frame.size.width, 1.0f);

bottomBorder.backgroundColor = self.BorderColor.CGColor;

[self.layer addSublayer:bottomBorder];

Everything is working fine upto iphone 5s but when i run in iphone 6 and above it's border size decrease. like if width of textfield is 120 border show only upto 100 . Don't know how to deal with That. Please Guide me through it

like image 519
Mad Burea Avatar asked Jan 18 '26 03:01

Mad Burea


1 Answers

If you want to deal with CALayer then Try this following life cycle method.

-(void)viewDidLayoutSubviews
{
    CALayer *bottomBorder = [CALayer layer];
    bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.layer.frame.size.width, 1.0f);
    bottomBorder.backgroundColor = self.BorderColor.CGColor;
    [self.layer addSublayer:bottomBorder];
}
like image 169
Maulik shah Avatar answered Jan 20 '26 18:01

Maulik shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!