【发布时间】:2014-04-15 13:58:46
【问题描述】:
我想知道在使用
UIView:
UIView *box = [[UIView alloc] initWithFrame:CGRectMake(ax, ay, width, height)];
box.backgroundColor = [UIColor clearColor];
box.layer.borderColor = [UIColor whiteColor].CGColor;
box.layer.borderWidth = lineWidth;
[self.view addSubview:box];
或CGContext:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, lineWidth);
CGContextSetStrokeColorWithColor(context, color.CGColor);
CGContextMoveToPoint(context, ax, ay);
CGContextAddLineToPoint(context, ax+width, ay);
CGContextAddLineToPoint(context, ax+width, ay+height);
CGContextAddLineToPoint(context, ax, ay+height);
CGContextAddLineToPoint(context, ax, ay);
CGContextStrokePath(context);
【问题讨论】:
-
这个问题的唯一答案应该是衡量,看看什么对您的确切用例最有效。
标签: ios objective-c performance uiview cgcontext