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 将目标C转换为单触式(圆形表格分组)_Xamarin_Xamarin.ios_Monotouch.dialog - Fatal编程技术网

Xamarin 将目标C转换为单触式(圆形表格分组)

Xamarin 将目标C转换为单触式(圆形表格分组),xamarin,xamarin.ios,monotouch.dialog,Xamarin,Xamarin.ios,Monotouch.dialog,我有以下目标C代码: CGFloat转弯半径=5.f; cell.backgroundColor=UIColor.clearColor; CAShapeLayer*layer=[[CAShapeLayer alloc]init]; CGMutablePathRef pathRef=CGPathCreateMutable(); CGRect-bounds=CGRectInset(cell.bounds,10,0); BOOL addLine=否; if(indexPath.row==0&&inde

我有以下目标C代码:

CGFloat转弯半径=5.f;
cell.backgroundColor=UIColor.clearColor;
CAShapeLayer*layer=[[CAShapeLayer alloc]init];
CGMutablePathRef pathRef=CGPathCreateMutable();
CGRect-bounds=CGRectInset(cell.bounds,10,0);
BOOL addLine=否;
if(indexPath.row==0&&indexPath.row===[tableView numberOfRowsInSection:indexPath.section]-1){
CGPathAddRoundedRect(路径参考、零、边界、拐角半径、拐角半径);
}else if(indexPath.row==0){
CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(边界),CGRectGetMaxY(边界));
CGPathAddArcToPoint(路径参考、零、CGRectGetMinX(边界)、CGRectGetMinY(边界)、CGRectGetMidX(边界)、CGRectGetMinY(边界)、cornerRadius);
CGPathAddArcToPoint(路径参考、零、CGRectGetMaxX(边界)、CGRectGetMinY(边界)、CGRectGetMaxX(边界)、CGRectGetMidY(边界)、cornerRadius);
CGPathAddLineToPoint(pathRef,nil,CGRectGetMaxX(边界),CGRectGetMaxY(边界));
addLine=是;
}else if(indexPath.row==[tableView numberOfRowsInSection:indexPath.section]-1){
CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(边界),CGRectGetMinY(边界));
CGPathAddArcToPoint(路径参考、零、CGRectGetMinX(边界)、CGRectGetMaxY(边界)、CGRectGetMidX(边界)、CGRectGetMaxY(边界)、cornerRadius);
CGPathAddArcToPoint(路径参考、零、CGRectGetMaxX(边界)、CGRectGetMaxY(边界)、CGRectGetMaxX(边界)、CGRectGetMidY(边界)、cornerRadius);
CGPathAddLineToPoint(路径参考、零、CGRectGetMaxX(边界)、CGRectGetMinY(边界));
}否则{
CGPathAddRect(pathRef,nil,bounds);
addLine=是;
}
layer.path=pathRef;
CFRelease(pathRef);
layer.fillColor=[UIColor colorWithWhite:1.f alpha:0.8f].CGColor;
如果(addLine==是){
CALayer*lineLayer=[[CALayer alloc]init];
CGFloat线宽=(1.f/[UIScreen Main Screen]。比例);
lineLayer.frame=CGRectMake(CGRectGetMinX(bounds)+10,bounds.size.height-lineHeight,bounds.size.width-10,lineHeight);
lineLayer.backgroundColor=tableView.separatorColor.CGColor;
[图层添加子图层:lineLayer];
}
UIView*testView=[[UIView alloc]initWithFrame:bounds];
[testView.layer insertSublayer:layer atIndex:0];
testView.backgroundColor=UIColor.clearColor;
cell.backgroundView=testView;
我翻译成C#(Xamarin):

float cornerRadius=5f;
cell.BackgroundColor=UIColor.Clear;
CAShapeLayer层=新的CAShapeLayer();
CGPath pathRef=新的CGPath();
矩形边界=新的矩形边界(cell.bounds.X,cell.bounds.Y,5,0);
bool addLine=false;
if(indexPath.Row==0&&indexPath.Row==tableView.numberofrowsinssection(indexPath.Section)-1){
pathRef.AddRoundedRect(边界、拐角半径、拐角半径);
}else if(indexPath.Row==0){
pathRef.MoveToPoint(bounds.GetMinX(),bounds.GetMaxY());
pathRef.AddArcToPoint(bounds.GetMinX()、bounds.GetMinY()、bounds.GetMidX()、bounds.GetMinY()、cornerRadius);
pathRef.AddArcToPoint(bounds.GetMaxX()、bounds.GetMinY()、bounds.GetMaxX()、bounds.GetMidY()、cornerRadius);
pathRef.AddLineToPoint(bounds.GetMaxX(),bounds.GetMaxY());
addLine=true;
}else if(indexPath.Row==tableView.NumberOfRowsInSection(indexPath.Section)-1){
pathRef.MoveToPoint(bounds.GetMinX(),bounds.GetMinY());
pathRef.AddArcToPoint(bounds.GetMinX()、bounds.GetMaxY()、bounds.GetMidX()、bounds.GetMaxY()、cornerRadius);
pathRef.AddArcToPoint(bounds.GetMaxX()、bounds.GetMaxY()、bounds.GetMaxX()、bounds.GetMidY()、cornerRadius);
pathRef.AddLineToPoint(bounds.GetMaxX(),bounds.GetMinY());
}否则{
pathRef.AddRect(边界);
addLine=true;
}
layer.Path=pathRef;
//CFRelease(pathRef);
layer.FillColor=新的CGColor(1f,0.8f);//UIColor.FromWhiteAlpha(1f,0.8f);
如果(添加行){
CALayer lineLayer=新CALayer();
浮动线高度=(1f/UIScreen.MainScreen.Scale);
lineLayer.Frame=新矩形F(bounds.GetMinX()+10,bounds.Size.Height-lineHeight,bounds.Size.Width-10,lineHeight);
lineLayer.BackgroundColor=tableView.SeparatorColor.CGColor;
layer.AddSublayer(lineLayer);
}
UIView testView=新UIView(边界);
testView.Layer.InsertSublayer(层,0);
testView.BackgroundColor=UIColor.Clear;
cell.BackgroundView=testView;
但它现在可以工作了,我在构建时没有遇到应用程序崩溃或错误

我想通过这个问题实现以下目标:

谢谢你的帮助