简体   繁体   中英

How to create “Embossed” effect on a text in iOS?

I wanted to create " Embossed " text effect on a text in a UILabel. I am not able to choose a right option. Please guide me on how to implement this with the right available options. Do i need to use CoreGraphics or CoreText or Customized UILabel ?. I just want the way how numbers appear on a Credit Card.

在此处输入图片说明

Try this,

[label setShadowColor:[UIColor darkGrayColor]];
[label setShadowOffset:CGSizeMake(0, -1)];

You can tweak this to get the desired effect.

UILabel's shadowColor and shadowOffset offer a limited customisation. You could also override UILabel's drawRect:

-(void)drawTextInRect:(CGRect)rect
{
    CGContextRef ref = UIGraphicsGetCurrentContext();
    CGContextSetShadowWithColor(ref, CGSizeMake(0.0, 2.0), 3.0, [UIColor blackColor].CGColor);
    [super drawTextInRect:rect];
}

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