這是我用於繪製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