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)