drawRect not being called in my subclass of UIImageView

前端 未结 4 1319
谎友^
谎友^ 2020-12-01 05:24

I have subclassed UIImageView and tried to override drawRect so I could draw on top of the image using Quartz 2D. I know this is a dumb newbie question, but I\'m not seeing

4条回答
  •  执念已碎
    2020-12-01 05:56

    Try to add

    Edit:

    - (id)initWithFrame:(CGRect)frame{
        if (self = [super initWithFrame:frame]) {
            [self setClearsContextBeforeDrawing:YES];//add this line also
        }
        return self;
    }
    
    
    - (void)setNeedsDisplay{
        [self setNeedsDisplayInRect:self.frame];
    }
    

    into your code.

    hope this helps.

    Thanks,

    madhup

提交回复
热议问题