如何制作@“Hello World!”的影子在下面的代码?
提前致谢!!
UILabel *lbl = [[UILabel alloc]init];
lbl.frame = CGRectMake(0,0,150,50);
lbl.text = @"Hello World!";
答案 0 :(得分:5)
使用attributedString
代码
UILabel * Label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 60)];
[self.view addSubview:Label];
NSMutableAttributedString * mutableAttriStr = [[NSMutableAttributedString alloc] initWithString:@"Wenchen"];
NSShadow * shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor blueColor];
shadow.shadowBlurRadius = 2.0;
shadow.shadowOffset = CGSizeMake(1.0, 1.0);
NSDictionary * attris = @{NSShadowAttributeName:shadow};
[mutableAttriStr setAttributes:attris range:NSMakeRange(0,mutableAttriStr.length)];
Label.attributedText = mutableAttriStr;
答案 1 :(得分:2)
serial_num
答案 2 :(得分:0)
UILabel *label = [[UILabel alloc]init];
label.frame = CGRectMake(0,0,150,50);
label.text = @"Hello World!";
label.layer.shadowColor = [label.textColor CGColor];
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);
导入 并使用一些参数:
label.layer.shadowRadius = 3.0;
label.layer.shadowOpacity = 0.5
label.layer.masksToBounds = NO;
答案 3 :(得分:0)
testLabel.shadowColor = [UIColor blackColor];
testLabel.shadowOffset = CGSizeMake(0.0, -0.5);