I am creating a UIButton similar to this image:
I tried it by using following code:
+(void)createShadowOnView:(UIView *)view color:(UIColor *)color width:(CGFloat)width height:(CGFloat)height shadowOpacity:(CGFloat)shadowOpacity andShadowRadius:(CGFloat)radius{
view.layer.masksToBounds = NO;
view.layer.shadowColor = color.CGColor;
view.layer.shadowOffset = CGSizeMake(width,height);
view.layer.shadowOpacity = shadowOpacity;
[view.layer setShadowRadius:radius];
}
I was able to achieve this:
I want shadow effect on Button to be kept only on bottom part.
How can I achieve desired effect.
Maybe you should set view's backgroundcolor, so the title has no shadow, you can set view.layer.shadowOffset to change the shadow size.
UIButton *customBTn = [UIButton buttonWithType:UIButtonTypeCustom];
customBTn.backgroundColor = [UIColor whiteColor];
customBTn.frame = CGRectMake(100, 100, 200, 50);
[customBTn setTitle:@"Sign Up" forState:UIControlStateNormal];
[customBTn setTitleColor:[UIColor colorWithRed:1/255.0 green:168/255.0 blue:244/255.0 alpha:1.0] forState:UIControlStateNormal];
customBTn.layer.borderColor = [UIColor colorWithRed:1/255.0 green:168/255.0 blue:244/255.0 alpha:1.0].CGColor;
customBTn.layer.borderWidth = 2;
customBTn.layer.cornerRadius = 25;
customBTn.layer.shadowColor = [UIColor lightGrayColor].CGColor;
customBTn.layer.shadowOffset = CGSizeMake(0,8);
customBTn.layer.shadowOpacity = 0.9;
[self.view addSubview:customBTn];
Output :-
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