iPhone UILabel text soft shadow

前端 未结 15 932
时光取名叫无心
时光取名叫无心 2020-12-07 09:31

I know soft shadows are not supported by the UILabel out of the box, on the iPhone. So what would be the best way to implement my own one?

EDIT:

15条回答
  •  [愿得一人]
    2020-12-07 10:16

    As of iOS 5 Apple provides a private api method to create labels with soft shadows. The labels are very fast: I'm using dozens at the same time in a series of transparent views and there is no slowdown in scrolling animation.

    This is only useful for non-App Store apps (obviously) and you need the header file.

    $SBBulletinBlurredShadowLabel = NSClassFromString("SBBulletinBlurredShadowLabel");
    
    CGRect frame = CGRectZero;
    
    SBBulletinBlurredShadowLabel *label = [[[$SBBulletinBlurredShadowLabel alloc] initWithFrame:frame] autorelease];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:12];
    label.text = @"I am a label with a soft shadow!";
    [label sizeToFit];
    

提交回复
热议问题