0
我有兩個框架上的點和線,我想做一個填充。如果兩行代碼在不同的框架上,CGContextRef是否可以填充?CGContextRef與兩個框架
我在計算它們是否包含相同的CGContextRef它不會有關係嗎?
繼承人的想法:
if(dp.gPoints == nil || dp.gPoints->size() < 1)
return;
CGContextRef UserGraphBuff = UIGraphicsGetCurrentContext();
CGContextBeginPath(UserGraphBuff);
vector<CGPoint>::iterator k = dp.gPoints->begin();
CGContextMoveToPoint(UserGraphBuff, (*k).x, (*k).y);
++k;
CGContextSetStrokeColorWithColor(UserGraphBuff, [UIColor blackColor].CGColor);
while(k != dp.gPoints->end()){
CGContextAddLineToPoint(UserGraphBuff, (*k).x, (*k).y);
++k;
}
vector<CGPoint>::iterator L = dp.dPoints->end();
while(L != dp.dPoints->begin()){
CGContextAddLineToPoint(UserGraphBuff, (*L).x, (*L).y);
--L;
}
CGContextAddLineToPoint(UserGraphBuff, (*k).x, (*k).y);
CGContextSetFillColor(UserGraphBuff, CGColorGetComponents([[UIColor greenColor] CGColor]));
CGContextClosePath(UserGraphBuff);
CGContextEOFillPath(UserGraphBuff);
也許有我的代碼,這也解釋了爲什麼這是不工作的問題。 任何信息都會很棒。 謝謝。
我發現這個問題發佈之前不久。它與如何使用drawRect有關。 –