almost 10 years ago
Hi,
The tutorial will help you to set underline textfield in Xcode.
- #import "UnderlinedTextField.h"
- @implementation UnderlinedTextField
- // Only override drawRect: if you perform custom drawing
- // An empty implementation adversely affects performance during animation.
- -(void)drawRect:(CGRect)rect {
- // Drawing code
- CALayer *bottomBorder = [CALayer layer];
- bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.frame.size.width, 1.0f);
- bottomBorder.backgroundColor = [UIColor lightGrayColor].CGColor;
- [self.layer addSublayer:bottomBorder];
- }
- @end
#import "UnderlinedTextField.h" @implementation UnderlinedTextField // Only override drawRect: if you perform custom drawing // An empty implementation adversely affects performance during animation. -(void)drawRect:(CGRect)rect { // Drawing code CALayer *bottomBorder = [CALayer layer]; bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.frame.size.width, 1.0f); bottomBorder.backgroundColor = [UIColor lightGrayColor].CGColor; [self.layer addSublayer:bottomBorder]; } @end
Just add this category to your xcode project and select the textfield and go to the IB and give the name UnderlinedTextField to your textfield class and use it.
0 Comment(s)