UIButton阴影颜色和阴影偏移不显示

时间:2013-05-08 00:57:34

标签: ios uibutton layer

阴影不起作用,为什么?我写了一个UiBarbuttonItem,例如:

 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];

1 个答案:

答案 0 :(得分:2)

您需要将shadowOpacity设置为大于0的内容。