Using below code for shadow in outside for UIButton. But how can i get shadow for inside the button
button.imageView.layer.cornerRadius = 7.0f;
button.layer.shadowRadius = 3.0f;
button.layer.shadowColor = [UIColor blackColor].CGColor;
button.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
button.layer.shadowOpacity = 0.5f;
button.layer.masksToBounds = NO;
#define kDEFAULT_SHADOW_COLOR [UIColor lightGrayColor]
UIColor *color = [kDEFAULT_SHADOW_COLOR colorWithAlphaComponent:0.3f];
NSArray *colorsArray = @[(id)[color CGColor], (id)[[UIColor clearColor] CGColor]];
CGFloat yOffset = 0.0f;
CGFloat leftHeight = button.bounds.size.height;
CAGradientLayer *shadow;
shadow = [CAGradientLayer layer];
shadow.colors = colorsArray;
shadow.frame = CGRectMake(0, yOffset, 5.0, leftHeight);
shadow.startPoint = CGPointMake(0.0, 0.5);
shadow.endPoint = CGPointMake(1.0, 0.5);
[button.layer insertSublayer:shadow atIndex:0];
You have not implemented the button shadows property. Add the following lines of code and show shadow. The Code is...
self.submitBtn.layer.masksToBounds = YES;
self.submitBtn.layer.clipsToBounds = YES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With