HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 我怎么能概述文字字体?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在其边框(轮廓)中显示另一种颜色的文本.
我正在尝试使用MapOverlayView显示文本
[text drawAtPoint:CGPointMake(0,30) withFont:[UIFont fontWithName:@"Helvetica-Bold" size:(3 * MKroadWidthAtZoomScale(zoomScalE))]

它工作正常,除了我需要文本显示轮廓.

解决方法

是的,您可以借助CGContextSetDrawingMode(CGContextRef,CGTextDrawingModE)显示轮廓文本,尽管您可能需要调整一些数字和颜色以使其看起来很好.

使用kCGTextFillstroke似乎合乎逻辑,但这可能会使笔划压倒填充.如果你抚摸,然后填充,如下面的块中,你会得到可读文本背后的可见轮廓.

CGContextRef context = UIGraphicsGetCurrentContext();

CGPoint point = CGPointMake(0,30);
CGFloat fontSize = (3 * MKroadWidthAtZoomScale(zoomScalE));
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];

// Draw outlined text.
CGContextSetTextDrawingMode(context,kCGTextstroke);
// Make the thickness of the outline a function of the font size in use.
CGContextSetLineWidth(context,fontSize/18);
CGContextSetstrokeColorWithColor(context,[[UIColor redColor] CGColor]);
[text drawAtPoint:point withFont:font];

// Draw filled text.  This will make sure it's clearly readable,while leaving some outline behind it.
CGContextSetTextDrawingMode(context,kCGTextFill);
CGContextSetFillColorWithColor(context,[[UIColor blueColor] CGColor]);
[text drawAtPoint:point withFont:font];

大佬总结

以上是大佬教程为你收集整理的ios – 我怎么能概述文字字体?全部内容,希望文章能够帮你解决ios – 我怎么能概述文字字体?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。