今天用了一下UILable的setShadowoffset方法,想通过此方法设置一下阴影,但是却发现没效果,代码如下:
UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(350, 450, 100, 30)];
lab.text = @"我的博客";
[lab setShadowOffset:CGSizeMake(5.8, 5.8)]
结果没有任何效果,我就尝试设置了一下shadowColor属性,发现有效果了,于是查了一下官方文档,原来此属性默认为nil,哎,真笨啊我。。。:
shadowColor
The shadow color of the text.
@property(nonatomic, retain)
UIColor *shadowColor
Discussion
The default value for this property is nil
, which indicates that no shadow is drawn. In addition to this property, you may also want to change the default shadow offset by modifying the shadowOffset
property. Text shadows are drawn with the specified offset and color and no blurring.