[英]Font Size change KerningAdjustment, why?
我解決了這個問題,我創建了一個 function 我只是傳遞了我需要的間距值和 TextField
public static void ChangeSpaceBetweenCharacters(this UITextField textField, float space)
{
textField.WeakDefaultTextAttributes.SetValueForKey(NSObject.FromObject((nfloat)space), UIStringAttributeKey.KerningAdjustment);
}
最好的問候, 拉斐爾桑托斯
我認為問題可能是由您使用的字體方法引起的,我無法使用:
UIFont("ArialMT", 13)
相反,您可以使用:
Font = UIFont.FromName("ArialMT", 13),
或者
Font = UIFont.SystemFontOfSize(10),
我測試下面的示例代碼,它適用於我:
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
NSMutableAttributedString mtText = new NSMutableAttributedString("testTextfield", new UIStringAttributes
{
Font = UIFont.SystemFontOfSize(10),
KerningAdjustment = 8.0f
});
UITextField textField = new UITextField();
textField.Frame = new CoreGraphics.CGRect(10,20,350,50);
textField.AttributedText = mtText;
Add(textField);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.