Trouble with red circle redraw


So I am having trouble when redrawing the circles to red. It just stays grey. Attached is my code. Granted I changes a couple things around when I was debugging. Also I am using the simulator. Can anyone see something that maybe I am missing?

When I run debugger and I look at the clr class I do see memory is getting allocation and isa [0] says Class error unknown class…not sure if that is related. It compiles with no errors or warnings.

Thanks in advance


#import <Foundation/Foundation.h>

@interface HypnosisView : UIView

@property (nonatomic, strong) UIColor *circleColor;
@property (nonatomic, strong) UIColor *clr;



#import "HypnosisView.h"

@implementation HypnosisView
@synthesize circleColor, clr;

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGRect bounds = [self bounds];
    float x = bounds.origin.x + bounds.size.width / 2.0;
    float y = bounds.origin.y + bounds.size.height / 2.0;
    //float maxRadius = hypot(bounds.size.width, bounds.size.height) / 4.0;
    float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2.0;
    CGContextSetLineWidth(ctx, 10);
    [[self circleColor] setStroke];
    //[[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1] setStroke];
    [[UIColor lightGrayColor] setStroke];
    //CGContextAddArc(ctx, x, y, maxRadius, 0.0, M_PI * 2.0, YES);
    for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20 ) {
        CGContextAddArc(ctx, x, y, currentRadius, 0.0, M_PI * 2, YES);
    NSString *text = @"You are getting sleepy.";
    UIFont *font = [UIFont boldSystemFontOfSize:28];
    CGRect textRect;
    textRect.size = [text sizeWithFont:font];
    textRect.origin.x = x - textRect.size.width / 2.0;
    textRect.origin.y = y - textRect.size.height / 2.0;
    [[UIColor blackColor] setFill];
    CGSize offset = CGSizeMake(4, 3);
    CGColorRef color = [[UIColor darkGrayColor] CGColor];
    CGContextSetShadowWithColor(ctx, offset, 2.0, color);

    [text drawInRect:textRect withFont:font];

    self = [super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor clearColor]];
    return self;

- (BOOL)canBecomeFirstResponder {
    return YES;

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
    if (motion == UIEventSubtypeMotionShake) {
    NSLog(@"Device started shaking!");
        clr = [UIColor redColor];
    [self setCircleColor:clr];


- (void)setCircleColor:(UIColor *)clr1 {
    circleColor = clr1;
  [self setNeedsDisplay];
    NSLog (@"Should of changed color..did it??");




I think the problem is that you are setting the stroke color back to gray before you draw the circles

in DrawRect:

[code][[self circleColor] setStroke]; // <------ stroke color set based on instance variable here…


//[[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1] setStroke];

[[UIColor lightGrayColor] setStroke]; // <----- but immediately set back to gray here[/code]