Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add Gradient effect to UIButton ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 630
    Comment on it

    Hello all !

    For adding Gradient effect to the UIButton we can implement the following code :-

    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    
    gradientLayer.frame = _customButton.layer.bounds;   // _customButton is the outlet of UIButton
        
    gradientLayer.colors = [NSArray arrayWithObjects:(id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,(id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,nil];
        
    gradientLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],[NSNumber numberWithFloat:1.0f],nil];
        
    gradientLayer.cornerRadius = _customButton.layer.cornerRadius;
       
    [_customButton.layer addSublayer:gradientLayer];
    

    It's done !

 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: