Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Underline and Border of UIButton

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 495
    Comment on it

    Hi all,

    To underline your button use this class :-

    .h

    @interface UnderLineButton : UIButton
    
    @end
    

    .m

    @implementation UnderLineButton
    - (void)drawRect:(CGRect)rect {
        // Drawing code
    
        CALayer *bottomBorder = [CALayer layer];
    
        bottomBorder.frame = CGRectMake(0.0f, self.frame.size.height-0.2, self.frame.size.width, 0.5f);
    
        bottomBorder.backgroundColor = [UIColor blackColor].CGColor;
    
        [self.layer addSublayer:bottomBorder];
        }
    
    @end
    

    To give border to UIButton use this class :-

    .h

    @interface BorderRoundButton : UIButton
    
    @end
    

    .m

    @implementation BorderRoundButton
    
    - (id)init
    {
        self = [super init];
        if (self) {
    
        }
        return self;
    }
    
    - (void)awakeFromNib
    {
        [super awakeFromNib];
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self setBackgroundColor:[UIColor whiteColor]];
        [self.layer setBorderColor:[UIColor blackColor].CGColor];
        [self.layer setBorderWidth:1.0];
    }
    @end
    

 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: