使用NSShadow來設置陰影屬性
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowBlurRadius = 2;//陰影半徑,默認值3
shadow.shadowColor = [UIColor blackColor];//陰影顏色
shadow.shadowOffset = CGSizeMake(0,2);//陰影偏移量,x向右偏移,y向下偏移,默認是(0,-3)
NSAttributedString * attributedText = [[NSAttributedString alloc] initWithString:@"test" attributes:@{NSShadowAttributeName:shadow}];
最后將富文本attributedText賦值給label就ok了