我正在尝试为UIButton图层添加阴影,但由于某种原因,它会在按钮的边界处切断。我设置了clipsToBounds关闭,所以我不确定为什么它看起来像这样:
这是正方形,就像那样,即使阴影不应该被平方......它应该是柔软和褪色。
button.clipsToBounds = NO;
button.layer.masksToBounds = NO;
button.layer.shadowOffset = CGSizeZero;
button.layer.shadowPath = [UIBezierPath bezierPathWithRect:button.layer.bounds].CGPath;
button.layer.shadowOpacity = 0.7;
button.layer.shadowColor = [UIColor blackColor].CGColor;
button.layer.shadowRadius = 10;
我错过了什么吗?
哦,我的按钮是UIButton的子类。我不确定这是否有所作为.. - 即使shadowDadius为0.0,我得到一个完全可见的黑色方块作为我的阴影
答案 0 :(得分:3)
clipsToBounds
将允许在按钮范围之外绘制任何子视图。
看起来它不适用于您的图层:(
你可能只需要让你的按钮更大(或者你的阴影更小!)