Xamarin 如何将UITextAttribute更改为新的字体大小和重量?
有人建议:Xamarin 如何将UITextAttribute更改为新的字体大小和重量?,xamarin,xamarin.forms,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.ios,有人建议: UITextAttributes att = new UITextAttributes(); att.Font = UIFont.SystemFontOfSize(20.0 , FontAttributes.Bold); // size and weight 然而,这给了我一个错误的设置数字和字体的重量。数字格式 Error CS1503: Argument 1: cannot convert from 'double' to 'System.nfloat' (CS1503)
UITextAttributes att = new UITextAttributes(); att.Font = UIFont.SystemFontOfSize(20.0 , FontAttributes.Bold); // size and weight
然而,这给了我一个错误的设置数字和字体的重量。数字格式
Error CS1503: Argument 1: cannot convert from 'double' to 'System.nfloat' (CS1503)
Error CS1503: Argument 2: cannot convert from 'Xamarin.Forms.FontAttributes' to 'UIKit.UIFontWeight' (CS1503)
第一个参数是一个
nfloat
,因此在数字中添加一个f
,第二个参数是一个UIFontWeight
枚举
例子:
关于:
UITextAttributes att = new UITextAttributes
{
Font = UIFont.SystemFontOfSize(20.0f, UIFontWeight.Bold)
};