我认为现在可以在 IOS 应用程序中强制您的数字在使用自定义字体时是等宽的。我找到了示例并使用了一些可以编译的代码,但我的数字间距仍然是成比例的。有没有人得到这个工作,如果是这样,我做错了什么?!
这是我的代码:
UIFont bigNumberFont = UIFont.FromName("Dosis-Light", 60f);
var originalDescriptor = bigNumberFont.FontDescriptor;
var attributes = new UIFontAttributes(new UIFontFeature(CTFontFeatureNumberSpacing.Selector.MonospacedNumbers),
new UIFontFeature((CTFontFeatureCharacterAlternatives.Selector)0));
var newDesc = originalDescriptor.CreateWithAttributes(attributes);
UIFont bigNumberMono = UIFont.FromDescriptor(newDesc, 60f);
lbCurrentPaceMinute.Font = bigNumberMono;
我的自定义字体渲染得很好,但我无法控制数字间距。任何建议都非常感谢!