如何设置UILabel文字阴影的透明度?
来源:5-13 UIImageView其它知识点
幕布斯2332854
2018-06-14 22:11:01
如题,具体方法,谢谢啦!
1回答
imoocLovers
2018-06-15
①直接设置UILabel中的shadowColor和shadowOffset属性可以为文字设置阴影,但是不能设置阴影的透明效果,如果想要实现,需要给lable的text添加阴影。
②下面是参考代码:
NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowBlurRadius = 20; shadow.shadowOffset = CGSizeMake(0, 0); shadow.shadowColor = [UIColor greenColor]; NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:@"多看多听多思考" attributes:@{NSShadowAttributeName:shadow}]; UILabel *lable2 = [[UILabel alloc] initWithFrame:CGRectMake(0,20, 300, 20)]; lable2.attributedText = attribute; [self.view addSubview:lable2];