简体   繁体   中英

IOS UILabel shadow generates weird upper shadow

I'm trying to apply a shadow to a UILabel, but I get an ugly upper shadow on the font.

As you can see the shadow is already far away from the font, but I'm getting this shadowed upper thingy... The font should be pure white.

Any idea? I could put another UILabel over it, but I think it's not the cleanest solution...

float width = 500.0f;
    UIShadowLabel *label = [[UIShadowLabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width * 0.5) - (width * 0.5), 150.0, width, 100.0) ];
    label.backgroundColor = [UIColor clearColor]; 
    label.shadowColor = UIColorFromRGB(0xb1b0b0);
    label.shadowRadius = 3.0f;
    label.shadowOffset = CGSizeMake(15.0f, 15.0f);
    label.textAlignment =  UITextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont fontWithName:@"Arial" size:(100.0)];
    [self.view addSubview:label];
    label.text = @"am";

在此处输入图片说明

Use below code as per your need

[self.yourView.layer setShadowColor:[UIColor blackColor].CGColor];
[self.yourView.layer setShadowOpacity:0.8];
[self.yourView.layer setShadowRadius:3.0];
[self.yourView.layer setShadowOffset:CGSizeMake(2.0, 2.0)];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM