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界,陰影裁剪。
任何幫助將不勝感激...