samedi 5 avril 2014

setNeedsDisplay not being called in view


Vote count:

0




I am changing the amount a bezier oval is being changed by each time the user presses a button. However, draw rect is only called once and when I call the method [self setNeedsDisplay], nothing happens. Is there a different way I should be approaching this?


Here is my code:



#import "CustomView.h"

@implementation CustomView

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}

-(void)awakeFromNib{
[self setup];
}

-(void)setup{
_scaleFactor = 0;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
UIBezierPath * circle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0, self.bounds.size.width - _scaleFactor, self.bounds.size.height - _scaleFactor)];
[[UIColor redColor]setStroke];
[[UIColor redColor]setFill];
[circle stroke];
[circle fill];
}

-(void)makeSmaller{
_scaleFactor -= 10;
[self setNeedsDisplay];
}

@end


asked 21 secs ago






Aucun commentaire:

Enregistrer un commentaire