shaonian
shaonian

Reputation: 41

UIButton shadow color and shadow offset don't show

the shadow doesn't work,why?I write a UiBarbuttonItem like ,ex:

 UIImage  *imageNomal     = [UIImage imageNamed:@"Back_A"];
 UIImage  *imageHight     = [UIImage imageNamed:@"Back_B"];
 UIButton *button    = [UIButton buttonWithType:UIButtonTypeCustom];
 button.bounds = CGRectMake(0, 0, imageNomal.size.width, imageNomal.size.height+2);
 [button.layer setShadowColor:[[UIColor whiteColor] CGColor]];
 [button.layer setShadowOffset:CGSizeMake(0, 2)];
 [button setImage:imageNomal forState:UIControlStateNormal];
 [button setImage:imageHight forState:UIControlStateHighlighted];
 [button addTarget:nav action:@selector(backClick:) forControlEvents:UIControlEventTouchUpInside];
 __autoreleasing UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

Upvotes: 4

Views: 992

Answers (1)

rob mayoff
rob mayoff

Reputation: 386038

You need to set shadowOpacity to something larger than 0.

Upvotes: 2

Related Questions