用动画在uiview上绘制图形

时间:2013-05-20 06:24:06

标签: iphone uitableview uiview calayer uiviewanimation

enter image description here

大家好,

我想在附图中创建一个类似的视图。我可以在UITableView的帮助下轻松完成此操作,但我还想在此tableView上方绘制图形。我正在计算一些数据,并根据该数据(%),我必须在该特定行上绘制我的图表(61-70%等)。此外,当图形到达特定行时,我还需要启动该特定行的计时器。我可以在uitableView之上绘制一个CALayer来实现这个目标吗?或者我通过创建CALayers创建一个带分区的自定义uiview并单独绘制图形。请建议。感谢

2 个答案:

答案 0 :(得分:2)

创建自定义视图和代码初始化 @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;
}

然后你可以传递UIColors数组和行数。

同样对于图表,您需要检查图表的原始值。

答案 1 :(得分:1)

是的,你可以查看tableview,但我的建议是使用自定义视图,因为你也可以访问任何计时器或起点。