将阴影效果应用于Objective-C中的文本

时间:2015-05-07 14:51:32

标签: ios objective-c uilabel

我是Objective-C编程的新手。 如何以编程方式将阴影效果应用于Objective-C中的文本?

这是我的代码:

[label setText:@"Some Text Data"];
[label setShadowColor:[UIColor whiteColor]];
[label setTextAlignment:NSTextAlignmentLeft];  
[label setFont:[UIFont fontWithName:@"HelveticaLTStd-Roman" size:19]];  
[label setTextColor:[UIColor colorWithRed:24.0f/255.0f green:24.0f/255.0f blue:24.0f/255.0f alpha:1.0]];

1 个答案:

答案 0 :(得分:1)

试试这个。

[label setText:@"Downloading Data"];
[label setShadowColor:[UIColor whiteColor]];
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);
label.layer.shadowRadius = 3.0;
label.layer.shadowOpacity = 0.5;
[label setTextAlignment:NSTextAlignmentLeft];
[label setFont:[UIFont fontWithName:@"HelveticaLTStd-Roman" size:19]];
[label setTextColor:[UIColor colorWithRed:24.0f/255.0f green:24.0f/255.0f blue:24.0f/255.0f alpha:1.0]];