C# 字体大小更改字距调整,为什么?

C# 字体大小更改字距调整,为什么?,c#,swift,xamarin.ios,kerning,C#,Swift,Xamarin.ios,Kerning,我解决了这个问题,我创建了一个函数,在这个函数中,我只需传递所需的间距值和文本字段 public static void ChangeSpaceBetweenCharacters(this UITextField textField, float space) { textField.WeakDefaultTextAttributes.SetValueForKey(NSObject.FromObject((nfloat)space), UIStringAttributeKey.Kernin

我解决了这个问题,我创建了一个函数,在这个函数中,我只需传递所需的间距值和文本字段

public static void ChangeSpaceBetweenCharacters(this UITextField textField, float space)
{
   textField.WeakDefaultTextAttributes.SetValueForKey(NSObject.FromObject((nfloat)space), UIStringAttributeKey.KerningAdjustment);

}
致以最良好的祝愿,
拉斐尔·桑托斯(Rafael Santos)

我认为这个问题可能是由您使用的字体方法造成的,我无法使它工作:

 UIFont("ArialMT", 13)
相反,您可以使用:

 Font = UIFont.FromName("ArialMT", 13),

我测试了下面的示例代码,它适用于我:

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);

}

谢谢你的帮助,但我认为这是VS for Mac和Xcode之间的通信问题。我找到的解决方案是更改Xcode中的字体,这样它就可以工作了。不过还是谢谢你。
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);

}