我想为我的UILabel添加一点阴影,但它没有显示出来。
companyLabel.textAlignment = UITextAlignmentLeft;
companyLabel.font = [UIFont fontWithName:@"Arial" size:13];
companyLabel.adjustsFontSizeToFitWidth = YES;
companyLabel.minimumFontSize = 10.0;
companyLabel.backgroundColor = [UIColor clearColor];
companyLabel.textColor = [UIColor colorWithRed:103.0/255.0 green:103.0/255.0 blue:103.0/255.0 alpha:1.0];
companyLabel.layer.shadowColor = [[UIColor colorWithRed:241.0/255.0 green:241.0/255.0 blue:241.0/255.0 alpha:1.0] CGColor];
companyLabel.layer.shadowOffset = CGSizeMake(0.0, -1.0);
companyLabel.highlightedTextColor = [UIColor whiteColor];
答案 0 :(得分:21)
您没有设置shadowOpacity
,默认为0.0
。您需要将其设置为其他内容以使阴影显示出来。但是,由于CALayer
拥有自己的UILabel
和shadowColor
属性,因此我们没有理由立即触摸shadowOffset
。
companyLabel.shadowColor = [UIColor colorWithRed:241.0/255.0 green:241.0/255.0 blue:241.0/255.0 alpha:1.0];
companyLabel.shadowOffset = CGSizeMake(0.0, -1.0);