开发者

Shadow on UILabel does not appear

开发者 https://www.devze.com 2023-03-31 16:58 出处:网络
I want to add a little shadow to my UILabel开发者_运维知识库, but it is not showing up. companyLabel.textAlignment = UITextAlignmentLeft;

I want to add a little shadow to my UILabel开发者_运维知识库, but it is not showing up.

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];


You're not setting shadowOpacity, which defaults to 0.0. You need to set that to something else to make the shadow show up. However, there's no reason to even touch CALayer right now because UILabel has its own shadowColor and shadowOffset properties.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号