我有圆角矩形 UIButton 并想为其添加阴影,但是当我设置背景图像阴影不可见时,我认为背景会覆盖阴影。没有背景图像阴影可见
customBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
customBtn.frame=CGRectMake(customBtn.frame.origin.x, customBtn.frame.origin.y, 30, 30);
[customBtn setImage:[UIImage imageNamed:@"icon.png"] forState:UIControlStateNormal];
[customBtn setBackgroundImage:[[UIImage imageNamed:@"bg.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:0] forState:UIControlStateNormal];
customBtn.layer.cornerRadius=9;
customBtn.layer.shadowColor = [UIColor redColor].CGColor;
customBtn.layer.shadowOpacity = 1.0;
customBtn.layer.shadowRadius = 1;
customBtn.layer.shadowOffset = CGSizeMake(2.0f, 2.0f);
customBtn.clipsToBounds=YES;