cool hit counter ios set border color for text_Intefrankly

ios set border color for text


WechatIMG15.jpeg

For example, to achieve an effect like this, of course, there may be ready-made third-party libraries, but a few lines of code can be done to import a library for this one function is still a bit costly, so we will implement their own

The code is simple.

/**
  hollow typeface

 @param str  copies
 @param textColor  Text Color
 @param textBorderColor  Text Border Color
 @param strokeWidth  Document border width
 @return  copies
 */
+(NSMutableAttributedString *)textHollow:(NSString *)str textColor:(UIColor *)textColor textBorderColor:(UIColor *)textBorderColor strokeWidth:(CGFloat)strokeWidth
{
    NSDictionary *dict = @{
                           NSStrokeColorAttributeName:textBorderColor,
                           NSStrokeWidthAttributeName : [NSNumber numberWithFloat:strokeWidth],
                           NSForegroundColorAttributeName:textColor
                           };
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:str attributes:dict];
    return attribtStr;
}

use

self.progressLabel.attributedText = [NSString textHollow:[NSString stringWithFormat:@"%.0f",progress] textColor:_progressColor textBorderColor:[UIColor lightGrayColor] strokeWidth:-3];

Note: strokeWidth should be set to a negative number, setting a positive number has no effect.


Recommended>>
1、Good news The university library has opened a foreign digital document library
2、Titanium Morning Apple iOS 13 to bring major update on iPad side says Bloomberg
3、The newest addition to the list is the newest addition to the list
4、15 High Profile Linux Tools
5、Features of blockchain technology

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号