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.87k
    Comment on it

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

    1. #import <UIKit/UIKit.h>
    2.  
    3. @interface UnderlinedTextField : UITextField
    4.  
    5. @end
    1. #import "UnderlinedTextField.h"
    2.  
    3. @implementation UnderlinedTextField
    4.  
    5. // Only override drawRect: if you perform custom drawing
    6. // An empty implementation adversely affects performance during animation.
    7. -(void)drawRect:(CGRect)rect {
    8. // Drawing code
    9.  
    10. CALayer *bottomBorder = [CALayer layer];
    11. bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height - 1, self.frame.size.width, 1.0f);
    12. bottomBorder.backgroundColor = [UIColor lightGrayColor].CGColor;
    13. [self.layer addSublayer:bottomBorder];
    14.  
    15. }
    16. @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
Reset Password
Fill out the form below and reset your password: