开发者

Drawing in UIView stops working if view width becomes greater than about 16600

开发者 https://www.devze.com 2023-01-27 01:02 出处:网络
I am using following code to plot graph in a view (in the drawRect method): CGContextBeginPath(context);

I am using following code to plot graph in a view (in the drawRect method):

CGContextBeginPath(context);
CGContextMoveToPoint(context, devicePoint.x, devicePoint.y);

for (index = 1; index < dataCount; index++) {
    devicePoint = [[deviceDataArray objectAtIndex:index] CGPointValue];
    CGContextAddLineToPoint(context, devicePoint.x, devicePoint.y);
}

CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextStrokePath(context);

It works if the view.bounds.size.width is less than about 16600. Bu开发者_开发知识库t above that size the plot stops appearing.

I resize the view depending on the range of the data to be plotted.


This is very bad idea to make such huge width for view, you must draw only what user can see in one time (or a little more) and use view of normal (screen) size for this. For controlling where user currently is use UIScrollView.


You are probably better off using CAShapeLayers to do the drawing, as they have no actual pixels, just a path that the hardware draws. Then you could have a UIScrollView which just exposed parts of the CAShapeLayers for drawing, otherwise you are making a huge image with the view as large as you have it currently.

0

精彩评论

暂无评论...
验证码 换一张
取 消