[英]How to create “Embossed” effect on a text in iOS?
I wanted to create " Embossed " text effect on a text in a UILabel. 我想在UILabel中的文本上创建“ Embossed ”文本效果。 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 ?. 我是否需要使用CoreGraphics或CoreText或自定义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. UILabel的shadowColor
和shadowOffset
提供了有限的自定义。 You could also override UILabel's drawRect:
您还可以覆盖UILabel的drawRect:
-(void)drawTextInRect:(CGRect)rect
{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGContextSetShadowWithColor(ref, CGSizeMake(0.0, 2.0), 3.0, [UIColor blackColor].CGColor);
[super drawTextInRect:rect];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.