旋转针头进行声级计

时间:2013-05-10 13:01:49

标签: cocoa-touch audio rotation

所以我正在建立一个声级计应用程序,我想在一个半圆形的速度计式视图中旋转一个针关于它从麦克风接收的输入。我知道麦克风给我一个输出,因为我可以在标签上打印它的结果,这个值会改变(在-40到-90之间),但是我的针没有移动,我不知道为什么?

继承我的代码:

-(void) addMeterViewContents
{
UIImage *Needle2 = [UIImage imageNamed:@"Needle.png"];
UIImageView *Needle = [[UIImageView alloc] initWithImage:Needle2];
[Needle setFrame:CGRectMake(159, 108, 2, 100)];
self.needleImageView = Needle;
[self.view addSubview:Needle];
angle=([recorder averagePowerForChannel:0])*5000000000;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2]; // Set how long your animation goes for
[UIView setAnimationBeginsFromCurrentState:YES];
needleImageView.layer.anchorPoint = CGPointMake(0, 0);
needleImageView.transform = CGAffineTransformRotate(needleImageView.transform, angle *   M_PI/180);

[UIView commitAnimations];
}

我看了下面的问题: How to rotate a needle (for a sound level meter) about it origin?

但这并没有给我答案。

0 个答案:

没有答案