เหตุใด UIBezierPath จึงเร็วกว่า Core Graphics path
ฉันกำลังเล่นกับเส้นทางการวาดและฉันสังเกตเห็นว่าอย่างน้อยในบางกรณี UIBezierPath ก็ทำได้ดีกว่าสิ่งที่ฉันคิดว่าจะเทียบเท่ากับ Core Graphics -drawRect:วิธีการดังต่อไปนี้จะสร้างสองเส้นทางหนึ่ง UIBezierPath และหนึ่ง CGPath เส้นทางจะเหมือนกันยกเว้นตำแหน่งของมัน แต่การลูบ CGPath จะใช้เวลาประมาณสองเท่าเมื่อลาก UIBezierPath - (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); // Create the two paths, cgpath and uipath. CGMutablePathRef cgpath = CGPathCreateMutable(); CGPathMoveToPoint(cgpath, NULL, 0, 100); UIBezierPath *uipath = [[UIBezierPath alloc] init]; [uipath moveToPoint:CGPointMake(0, 200)]; // Add 200 curve …