1

我正在尝试这样做:

所需的行程

所以我正在使用这段代码:

[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);

我也尝试用所需的颜色制作另一个标签并将其绘制在文本后面,但如果我正在使用文本的大小,它会影响所有文本的宽度。我怎样才能使笔画变粗?

我不能使用图像,因为我在这个文本中有一个应该是可变的数字。

谢谢

4

1 回答 1

2

这是解决方案:

- (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];
}
于 2013-09-23T09:58:58.250 回答