On Jun 19, 2009, at 12:20 PM, Chunk 1978 wrote:

i'm "attempting" to add a stroke to a rect, and i realized that
NSBezierPath is not available on iPhone SDK, so i'm forced to subclass
the rect...

I would probably start by looking at the QuartzDemo sample code at <http://developer.apple.com/iPhone/library/samplecode/QuartzDemo/ >

my StrokeView:UIView class.m is this:

- (id)initWithFrame:(CGRect)frame {
   if (self = [super initWithFrame:frame]) {
      frame = CGRectMake(10, 10, 100, 100);
   }

Changing frame here does nothing. In general you should not change the frame anyway - it is set to what the creator of the view wants it to be.

- (void)drawRect:(CGRect)rect
        {
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
        CGContextStrokePath(context);
        }

You have not added anything to the current path, so there is nothing to draw. If you want to stroke a rectangle, then you need to add one to the path before you stroke it. See the RectDrawingView demo in the QuartzDemo sample.

#import "StrokeView.h"
[self.view insertSubview:strokeViewClass atIndex:1];

totally doesn't work.

Where did you create the view? If you didn't create a view (either by alloc/initWithFrame: or by adding it in a NIB and setting up an outlet) then strokeViewClass is likely nil.
--
David Duncan
Apple DTS Animation and Printing

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to