2014-07-11 66 views
0

我是xcode的新手。这是我第一个应用程序。在这个应用程序中,我需要显示车辆的RPM,并从JSON服务获取RPM数据。但我不知道如何使用图形来显示它。请建议我解决这个问题。提前致谢。如何使用某些图形在xcode中显示车辆的RPM

+0

什么是RPM?请更清楚 –

+0

@BogdanSomlea RPM表示每分钟旋转速度计算器 – iBeginner

+0

,您想如何以图形方式显示它? –

回答

-1

您想将RPM显示为条形图吗?你可以为此使用UIView。

_graph = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 20)]; 
[_graph setBackgroundColor:[UIColor redColor]]; 
[self.view addSubview:_graph]; 

和RPM设置方法:

- (void)setRPM:(NSInteger)rpm 
{ 
    const NSInteger maxRPM  = 2000; 
    const NSInteger maxWidth = 200; 
    [UIView animateWithDuration:0.5 
       animations:^{ 

        CGRect frame = _graph.frame; 
        frame.size.width = maxWidth * (rpm/maxRPM); 
        _graph.frame = frame; 

       }]; 
} 

现在,你可以改变大小吧...

[self setRPM:1000] 

这个怎么样?

+0

当你投票,添加一些解释。 – Ryan

+0

对不起,我不能正确地得到你的答案。你能解释更多吗?否则请给我一些例子下载链接谢谢.. – iBeginner