On my iPhone app, I would need to draw a kind of full gauge with a dynamic indicator. I was thinking of using a gauge image (a .png, that I would draw in an external tool) without any indicator, and then draw the dynamic indicator on top of the image. I was thinking of using a UIView with this image in backgr开发者_运维知识库ound and then then use CoreGraphics (that I've never tried) to draw the indicator.
Do you think it's the easiest way to do this ?
thanks a lot,
Luc
I think you can't have a background image in the same view.
1°) You draw the image each time drawRect() is called
2°) You have two UIView, one who have the background image, and the other one which draw your gauge ;-)
Good Luck !
(I think the easiest method is the second one which don't re-draw the background each time :-))
Luc,
Your approach should work fine. Create a custom UIView and override -drawRect:
to first draw the background PNG of the gauge, then draw the indicators.
- (void) drawRect: (CGRect) rect {
\\ draw the gauge PNG into the view bounds
...;
\\ Now use Quartz to draw the indicators
...;
}
精彩评论