Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin 如何将UITextAttribute更改为新的字体大小和重量?_Xamarin_Xamarin.forms_Xamarin.ios - Fatal编程技术网

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