Reputation: 1070
I want to apply shadow effect to text of type NSString. Though I understand how to apply shadow effect to UILabel and other view elements, I can't figure out a way of adding shadow effect to text.
I am currently drawing text as follows:
NSString *text = @"Hello";
[text drawAtPoint:point width withFont:font minFontSize:22.0f actualFontSize:&actualFontSize lineBreakMode:UILineBreakModeTailTruncation baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
I would really appreciate any help. Thanks!
Upvotes: 0
Views: 496
Reputation: 4921
Try CGContextSetShadow()
for adding shadow to text
- (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]];
}
Upvotes: 2