我目前正在将 XCode
/Swift
中的 iOS
应用程序翻译成 Xamarin
iOS
.
在现有的swift代码中,有一个自定义控件继承自UIView
,并覆盖了drawLayer
函数。
但是,当我尝试在 Xamarin
的 UIView
自定义控件中覆盖同一成员时,没有覆盖。
谁能帮我弄清楚我做错了什么。
谢谢
最佳答案
此方法不存在直接使用,您必须使用 CALayer 类本身。
例如
public class BlueView : UIView
{
[Export ("layerClass")]
public static Class GetLayerClass ()
{
return new Class (typeof (BlueLayer));
}
public override void Draw (RectangleF rect)
{
// Do nothing, the Layer will do all the drawing
}
}
public class BlueLayer : CALayer
{
public override void DrawInContext (CGContext ctx)
{
ctx.SetFillColor (0, 0, 1, 1);
ctx.FillRect (Bounds);
}
}
引用:
关于ios - Xamarin iOS UIView 没有 DrawLayer 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36197322/