1
因为UIButton.titleLabel.shadowOffset特性使得阴影尖锐,我改变drawTextInRect方法来创建自定义半径的阴影象下面这样:UIButton.titleLabel阴影剪裁
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
float colorValues[] = {0, 0, 0, opacity};
CGColorRef shadowColor = CGColorCreate(colorSpace, colorValues);
CGSize shadowOffset = CGSizeMake(offsetX, offsetY);
CGContextSetShadowWithColor (context, shadowOffset, radius, shadowColor);
这工作得很好。它创造了阴影。我改变titleLabel的界限,并呼吁drawTextInRect方法,如:
button.titleLabel.bounds = CGRectMake(button.titleLabel.bounds.origin.x, button.titleLabel.bounds.origin.y, button.titleLabel.bounds.size.width, button.titleLabel.bounds.size.height);
[button.titleLabel drawTextInRect:button.titleLabel.bounds];
[button setNeedsLayout];
由于titleLabel界,阴影裁剪。
任何帮助将不胜感激...