Glenn
Glenn

Reputation: 2806

drawing shapes & Buttons

The learning curve for iPhone development has been less steep than I expected. After following some tutorials and the excellent book "Beginning iPhone 3 Development" by Apress things have gone quite ok. And of course when I got stuck this forum has been a great help so far. Until now I never did any 'graphical' programming on any platform I worked on in the past so this is highly uncharted territory for me in general en on the iPhone specific. I haven't been able to find a great source for info yet so I hope that some here can either help me directly or pinpoint me to a source (book, site) with the walhalla of drawing ;)

What I want to make is a gantt chart like drawing. The blocks should have some text on it explaining what that block is about and a button (custom shape eg a star) where the user can tap on. The button needs to change color when it's toggled.

What I've been able to find and try out is: create a separate view, and then implement this code on that view:

- (void)drawRect:(CGRect)rect {
    //Get the CGContext from this view
    CGContextRef context = UIGraphicsGetCurrentContext();


    //Draw it
    CGContextStrokePath(context);

    //Draw a rectangle
    CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
    //Define a rectangle
    CGContextAddRect(context, CGRectMake(40.0, 10.0, 100.0, 60.0));
    //Draw it
    CGContextFillPath(context);
}

So far so good but I'm stuck now. My problems are:

a big TIA !!!

Upvotes: 0

Views: 470

Answers (1)

AechoLiu
AechoLiu

Reputation: 18408

About how to draw text and fix this into the rectangle, you can see this article. NSString UIkit addon provides some extra methods for drawing string with desired size.

Upvotes: 1

Related Questions