以下是建议:
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)
答案 0 :(得分:2)
第一个参数是nfloat
,因此为数字添加f
,第二个参数为UIFontWeight
枚举。
UITextAttributes att = new UITextAttributes
{
Font = UIFont.SystemFontOfSize(20.0f, UIFontWeight.Bold)
};
re:https://developer.xamarin.com/api/member/UIKit.UIFont.SystemFontOfSize/