Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to implement underline textfield in Xcode

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.85k
    Comment on it

    Hi,
    The tutorial will help you to set underline textfield in Xcode.

     #import <UIKit/UIKit.h>
    
        @interface UnderlinedTextField : UITextField
    
        @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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: