效果:
代码
-(NSMutableAttributedString *)useString:(NSString *)str{
NSDictionary *attri = @{NSStrokeWidthAttributeName:@3,NSStrokeColorAttributeName:[UIColor colorWithHexString:@"#373737" alpha:0.75]};
NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc]initWithString:str];
[aStr setAttributes:attri range:NSMakeRange(0, str.length)];
return aStr;
}
使用:
self.timeLabel.attributedText = [selfuseString:[NSStringstringWithFormat:@"%@/%@",timeString,self.totalTime]];
注意:
代码:
-(NSMutableAttributedString *)useString:(NSString *)str{
NSDictionary *attri = @{NSStrokeWidthAttributeName:@-3,NSStrokeColorAttributeName:[UIColor colorWithHexString:@"#373737" alpha:0.75],NSForegroundColorAttributeName:[UIColor whiteColor]};
NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc]initWithString:str];
[aStr setAttributes:attri range:NSMakeRange(0, str.length)];
return aStr;
}
当NSStrokeWidthAttributeName属性设置为3(正)时候里面字体颜色是看不清的描边颜色为主;
当设置为-3时候里面字体颜色是可以看清的