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
CATextLayer SetFont Xamarin iOS值不能为空_Xamarin_Xamarin.ios - Fatal编程技术网

CATextLayer SetFont Xamarin iOS值不能为空

CATextLayer SetFont Xamarin iOS值不能为空,xamarin,xamarin.ios,Xamarin,Xamarin.ios,我在iOS模拟器9.2版上遇到了这个错误 System.ArgumentNullException: Value cannot be null. Parameter name: handle 下面的代码仅适用于iOS模拟器8.1版 Font = UIFont.SystemFontOfSize(16); .... textLayer = new CATextLayer(); textLayer.ForegroundColor = TextColor.CGColor; textLayer.SetF

我在iOS模拟器9.2版上遇到了这个错误

System.ArgumentNullException: Value cannot be null.
Parameter name: handle
下面的代码仅适用于iOS模拟器8.1版

Font = UIFont.SystemFontOfSize(16);
....
textLayer = new CATextLayer();
textLayer.ForegroundColor = TextColor.CGColor;
textLayer.SetFont(CGFont.CreateWithFontName(Font.FontDescriptor.Family));
设置字体会触发上述错误

textLayer.SetFont(CGFont.CreateWithFontName(Font.FontDescriptor.Family));
  • iOS 9=系统字体为
    San Fransisco
  • iOS 8=系统字体为
    Helvetica Neue
使用
UIFont.FontDescriptor.Name
而不是
Family
。全名永远有效

*D.WriteLine(字体.FontDescriptor.Family)

*D.WriteLine(Font.FontDescriptor.Name)


`.SF UI Text`
`.SFUIText-Regular`
var Font = UIFont.SystemFontOfSize(16);
var textLayer = new CATextLayer();
textLayer.ForegroundColor = UIColor.Red.CGColor; // TextColor.CGColor;
textLayer.SetFont(CGFont.CreateWithFontName(Font.FontDescriptor.Name));