这是我用于绘制UIView的蒙版的代码。问题是,如果我有超过5个UIViews与屏幕上的面具它影响性能时拖动&下降UIViews: 如何才能提高?:下面绘图蒙版影响性能
+ (UIBezierPath *)roundedPathAtCenter:(CGPoint)center size:(CGSize)size corner:(CGFloat)corner
{
NSInteger width = size.width;
NSInteger height = size.height;
UIBezierPath *path = [UIBezierPath bezierPath];
// upper left corner
[path moveToPoint: CGPointMake(center.x - width/2.0f + corner/2.0f, center.y - height/2.0f + corner/2.0f)];
// path to top center
[path addQuadCurveToPoint: CGPointMake(center.x, center.y - height/2.0f) controlPoint: CGPointMake(center.x - width/2.0f + corner, center.y - height/2.0f)];
// path to upper right
[path addQuadCurveToPoint: CGPointMake(center.x + width/2.0f - corner/2.0f, center.y - height/2.0f + corner/2.0f) controlPoint: CGPointMake(center.x + width/2.0f - corner, center.y - height/2.0f)];
// path to mid right
[path addQuadCurveToPoint: CGPointMake(center.x + width/2.0f, center.y) controlPoint: CGPointMake(center.x + width/2.0f, center.y - height/2.0 + corner)];
// path to lower right
[path addQuadCurveToPoint: CGPointMake(center.x + width/2.0 - corner/2.0f, center.y + height/2.0f - corner/2.0f) controlPoint: CGPointMake(center.x + width/2.0f, center.y + height/2.0f - corner)];
// path to center bottom
[path addQuadCurveToPoint: CGPointMake(center.x, center.y + height/2.0f) controlPoint: CGPointMake(center.x + width/2.0 - corner, center.y + height/2.0)];
// path to lower left
[path addQuadCurveToPoint: CGPointMake(center.x - width/2.0f + corner/2.0f, center.y + height/2.0f - corner/2.0f) controlPoint: CGPointMake(center.x - width/2.0f + corner, center.y + height/2.0f)];
// path to mid left
[path addQuadCurveToPoint: CGPointMake(center.x - width/2.0f, center.y) controlPoint: CGPointMake(center.x - width/2.0f, center.y + height/2.0 - corner)];
// path to top left
[path addQuadCurveToPoint: CGPointMake(center.x - width/2.0f + corner/2.0f, center.y - height/2.0f + corner/2.0f) controlPoint: CGPointMake(center.x - width/2.0f, center.y - height/2.0f + corner)];
[path closePath];
return path;
}
的代码,而没有面具UIViews它的工作原理很快速
顺便说一句,你会发现仪器的核心动画模板的使用非常有助于量化和定位原因。 – matt