views:

93

answers:

1

I have a UIView subclass. This subclass has multiple subviews. Is it possible to draw a line using core graphics inside a subview that is part of the uiview subclass?

For example, I have a SampleView class, which is a subclass of UIView. Inside this class's header file is the property for UIView *sampleSubView, which is a subview of SampleView. Is it possible to draw a line inside of sampleSubView from the SampleView class implementation?

Thanks for your help! Josh

+2  A: 

If you are asking how a UIView subclass can draw a line on itself, then see the Quartz demo sample code. Basically, you'll override the view's drawRect: method, get the current graphics context, then draw whatever you like onto it.

If you are asking how one view can draw a line on another view, perhaps you need to rethink your architecture.

Brian
The way I'm going to solve this is to have another custom UIView (the subview) have methods to draw lines rather than worry about a hierarchy, thanks for your answer.
jleibsly2002