Iphone NSString的阴影效果
我想对NSString类型的文本应用阴影效果。 虽然我知道如何将阴影效果应用于UILabel和其他视图元素, 我想不出一种给文字添加阴影效果的方法 我目前正在绘制以下文本:Iphone NSString的阴影效果,iphone,ios,ipad,nsstring,shadow,Iphone,Ios,Ipad,Nsstring,Shadow,我想对NSString类型的文本应用阴影效果。 虽然我知道如何将阴影效果应用于UILabel和其他视图元素, 我想不出一种给文字添加阴影效果的方法 我目前正在绘制以下文本: NSString *text = @"Hello"; [text drawAtPoint:point width withFont:font minFontSize:22.0f actualFontSize:&actualFontSize lineBreakMode:UILineBreakModeTailTrunca
NSString *text = @"Hello";
[text drawAtPoint:point width withFont:font minFontSize:22.0f actualFontSize:&actualFontSize lineBreakMode:UILineBreakModeTailTruncation baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
我真的很感激任何帮助。谢谢 尝试
CGContextSetShadow()
向文本添加阴影
- (void)drawRect:(CGRect)rect
{
NSString *string = @"Hello World!";
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShadow(context, CGSizeMake(20.0f, 20.0f), 10.0f);
[string drawAtPoint:CGPointMake(100.0f, 100.0f) withFont:[UIFont boldSystemFontOfSize:36.0f]];
}
你可以在这篇文章中找到答案:[在这里输入链接描述][1][1]: