IOS - Working with autolayout and drawRect


I'm working with autolayout and I have a RoundView class (subview of UIButton) which drawRect method is:

- (void)drawRect:(CGRect)rect
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGFloat lineWidth = 0.0;
    CGContextSetLineWidth(context, lineWidth);
    CGContextSetFillColorWithColor(context, _currentBackgroundColor.CGColor);
    CGContextAddEllipseInRect(context, self.bounds);


Then I add it to self (a UIView), set its width and height using autolayout. Everything looks great. But when I change its size constraints (to have a bigger view), and call

[self layoutIfNeeded];

in an animation block, the circle pixels look bigger and ugly.

Do I do this the correct way ?

I just got it from this post !

The problem was that the os wasn't calling drawRect at each animation step. To force it, in RoundView's init:

self.contentMode = UIViewContentModeRedraw;