Iphone 为标签中的文本绘制粗笔划
我正在尝试这样做: 因此,我使用以下代码:Iphone 为标签中的文本绘制粗笔划,iphone,ios,objective-c,xcode,uilabel,Iphone,Ios,Objective C,Xcode,Uilabel,我正在尝试这样做: 因此,我使用以下代码: [self.lblRound setOutlineColor:[UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/255.0) alpha:1]]; self.lblRound.drawOutline = YES; lblRound.shadowColor = [UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/
[self.lblRound setOutlineColor:[UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/255.0) alpha:1]];
self.lblRound.drawOutline = YES;
lblRound.shadowColor = [UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/255.0) alpha:1];
lblRound.shadowOffset = CGSizeMake(0, 0);
但我得到的是:
我也尝试过以下代码:
[self.lblRound setOutlineColor:[UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/255.0) alpha:1]];
self.lblRound.drawOutline = YES;
lblRound.shadowColor = [UIColor colorWithRed:(68/255.0) green:(82/255.0) blue:(120/255.0) alpha:1];
lblRound.shadowOffset = CGSizeMake(0, 0);
我还尝试用所需的颜色制作另一个标签,并在文本后面绘制它,但如果我处理文本的大小,它会影响所有文本的宽度。
如何使笔划更粗
我不能使用图像,因为我的文本中有一个数字应该是可变的
谢谢这是解决方案:
- (void)drawRect:(CGRect)rect
{
UIFont *font=[UIFont fontWithName:@"VAGRoundedStd-Bold" size:40];
CGContextRef context = UIGraphicsGetCurrentContext();
string = lblRoundnumber;
CGSize fontWidth = [string sizeWithFont:font];
CGRect tempRect=rect;
tempRect.origin.x +=160-(fontWidth.width/2);
tempRect.origin.y +=high+42;
CGContextSetRGBStrokeColor(context, 68/255.0f, 82/255.0f, 120/255.0f, 1/1.0f);
CGContextSetRGBFillColor(context, 68/255.0f, 82/255.0f, 120/255.0f, 1/1.0f);
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetLineWidth(context, 11);
[string drawInRect:tempRect withFont:font];
CGContextSetRGBFillColor(context, 1,1,1,1);
CGContextSetTextDrawingMode(context, kCGTextFill);
[string drawInRect:tempRect withFont:font];
}