york
york

Reputation: 149

Draw graph on uiview with animation

enter image description here

Hello Everyone,

I would like to create a similar view like in the attached image. I can do this easily with the help of UITableView but I also want to draw a graph above of this tableView. I am calculating some data and based upon that data (%), I have to draw my graph on that particular row(61-70 % etc). Also when the graph reaches into specific row, i need to start the timer of that particular row also. Can i draw a CALayer above of uitableView to achieve this? or i create a custom uiview with partition and draw graphs individually by creating CALayers. Please suggest. Thanks

Upvotes: 0

Views: 322

Answers (2)

Deepak Srivastava
Deepak Srivastava

Reputation: 170

create a custom View and code init like @implementation CustomView

- (id)initWithFrame:(CGRect)frame numberOfRows:(int)rows color:(NSArray *)colors
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    int yAxis =0;
    for(int i =0 ;i<[colors count];i++)
    {
        UIView *_v = [[UIView alloc]initWithFrame:CGRectMake(0, yAxis, 320, 480/rows)];
        [_v setBackgroundColor:[colors objectAtIndex:i]];
        [self addSubview:_v];

        /* add label and timer label according to your need */

    }

    return self;
}

then you can pass array of UIColors and number of rows.

Also for graph you need to check the origin value of graph.

Upvotes: 2

Deepak Srivastava
Deepak Srivastava

Reputation: 170

Yes you can tableview but my suggestion will be to use custom view as in that you can access any timer or startpoint as well.

Upvotes: 1

Related Questions