Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.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
Ios CGContextSetShadow UITableViewCell性能_Ios_Performance_Uitableview_Core Graphics_Shadow - Fatal编程技术网

Ios CGContextSetShadow UITableViewCell性能

Ios CGContextSetShadow UITableViewCell性能,ios,performance,uitableview,core-graphics,shadow,Ios,Performance,Uitableview,Core Graphics,Shadow,我正在使用自定义UITableViewCell 所以在我的子类中,我覆盖了drawContentView:进行一些绘图 我正在画一个带阴影的圆形矩形,但由于阴影的存在,滚动速度非常慢。如果我删除它,滚动就可以了 这是我的密码: /// Fill cell color CGContextSetFillColorWithColor(context, __cgColorBCBEC1); CGContextFillRects(context, &rect, 1); /// Rounded re

我正在使用自定义UITableViewCell

所以在我的子类中,我覆盖了drawContentView:进行一些绘图

我正在画一个带阴影的圆形矩形,但由于阴影的存在,滚动速度非常慢。如果我删除它,滚动就可以了

这是我的密码:

/// Fill cell color
CGContextSetFillColorWithColor(context, __cgColorBCBEC1);
CGContextFillRects(context, &rect, 1);

/// Rounded rect
CGFloat radius = 5.0f;
__rrect.size.height = rect.size.height - 10.0f; // __rect represent my rounded CGRect
CGContextMoveToPoint(context, __rrect.origin.x, __rrect.origin.y + radius);
CGContextAddLineToPoint(context, __rrect.origin.x, __rrect.origin.y + __rrect.size.height - radius);
CGContextAddArc(context, __rrect.origin.x + radius, __rrect.origin.y + __rrect.size.height - radius, radius, M_PI_4, M_PI_2, 1);
CGContextAddLineToPoint(context, __rrect.origin.x + __rrect.size.width - radius, __rrect.origin.y + __rrect.size.height);
CGContextAddArc(context, __rrect.origin.x + __rrect.size.width - radius, __rrect.origin.y + __rrect.size.height - radius, radius, M_PI_2, 0.0f, 1);
CGContextAddLineToPoint(context, __rrect.origin.x + __rrect.size.width, __rrect.origin.y + radius);
CGContextAddArc(context, __rrect.origin.x + __rrect.size.width - radius, __rrect.origin.y + radius, radius, 0.0f, -M_PI_2, 1);
CGContextAddLineToPoint(context, __rrect.origin.x + radius, __rrect.origin.y);
CGContextAddArc(context, __rrect.origin.x + radius, __rrect.origin.y + radius, radius, -M_PI_2, M_PI, 1);

/// Set the shadow
CGContextSetFillColorWithColor(context, __cgGreyColorF5);
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, __zeroSize, 5.0f, __cgGreyColor33);
CGContextFillPath(context);
CGContextRestoreGState(context);

/// Draw some text and a single line

如何使用阴影获得良好的滚动性能?

使用阴影、角半径和遮罩无法获得良好的滚动性能。 唯一的诀窍是,有时你可以通过在你想要的地方添加一个图像来模拟阴影,并使其覆盖