Fonts 如何为UILabel中应用的自定义字体应用粗体和斜体?

Fonts 如何为UILabel中应用的自定义字体应用粗体和斜体?,fonts,xamarin.ios,uilabel,custom-font,Fonts,Xamarin.ios,Uilabel,Custom Font,对于UILabel,我应用了自定义字体,并尝试为该自定义字体应用粗体和斜体。但我无法做到这一点。对于默认字体,我可以实现它,但对于自定义字体,我不能。有可能实现吗。下面提供了代码片段: UILabel uILabel = new UILabel(); uILabel.Text = "MyText"; uILabel.Frame = new CGRect(10, 50, 350, 40); uILabel.Font = UIFont.FromName("Handlee

对于UILabel,我应用了自定义字体,并尝试为该自定义字体应用粗体和斜体。但我无法做到这一点。对于默认字体,我可以实现它,但对于自定义字体,我不能。有可能实现吗。下面提供了代码片段:

UILabel uILabel = new UILabel();
uILabel.Text = "MyText";
uILabel.Frame = new CGRect(10, 50, 350, 40);
uILabel.Font = UIFont.FromName("Handlee", 15);
UIFontDescriptor descriptor = uILabel.Font.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold);
if (descriptor != null)
 uILabel.Font = UIFont.FromDescriptor(descriptor, 30);
View.AddSubview(uILabel);

确保自定义字体有粗体和斜体版本。如果我们检查谷歌字体,我们会发现它只有一个常规版本。因此,您可以更改另一种字体(如),然后再次进行测试