I'm trying to stroke a rect around a UIImage. I have subclassed UIImageView with the following code but I get Nothing the drawRect: method is never called:

-(id)initWithImage:(UIImage *)image
{
        if(self= [super initWithImage:image])
        {
                
        }
        
        return self;
}

-(void)setSelected
{
        selected = YES;
        [self setNeedsDisplay];
}

-(void)deselect
{
        selected = NO;
        [self setNeedsDisplay];
}



- (void)drawRect:(CGRect)rect
{
        NSLog(@"ImageView Draw");
        [super drawRect:rect];
        if (selected) {
                CGContextRef ctx = UIGraphicsGetCurrentContext();
                
                
                CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 1);
                CGContextStrokeRect(ctx, self.frame);   
        }
        else{
                CGContextRef ctx = UIGraphicsGetCurrentContext();
                
                
                CGContextSetRGBStrokeColor(ctx, 1.0, 1.0, 1.0, 0.0);
                CGContextStrokeRect(ctx, self.frame);   
        }
        
}
_______________________________________________

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