NCSoundHistogram 0.1.7

NCSoundHistogram 0.1.7

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年4月

Nikola Corlija维护。



  • Nikola Corlija

基于https://github.com/faviomob/FVSoundWaveDemo并在其基础上进行了改进

  • 增加了播放动画
  • 更多的自定义设置,例如设置条形宽度

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install

示例

alt tag

要求

  • iOS 8 sdk

安装

NCSoundHistogram通过CocoaPods提供。要安装它,只需将以下行添加到Podfile中

pod "NCSoundHistogram"

用法

导入头文件

#import "NCSoundHistogram.h"

初始化NCSoundHistogram并将其作为视图添加

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NCSoundHistogram *soundHistogramView = [[NCSoundHistogram alloc] initWithFrame:CGRectMake(50, 50, 200, 100)];
    
    soundHistogramView.waveColor = [UIColor blueColor];
    soundHistogramView.animationColor = [UIColor cyanColor];
    soundHistogramView.drawSpaces = YES;
    soundHistogramView.barLineWidth = 2.5;
    
    [self.view addSubview:soundHistogramView];
}

在某个按钮点击或视图出现时设置音频文件

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"audio.m4a" ofType:nil]];
    soundHistogramView.soundURL = url;
    
    [soundHistogramView animatePlayingWithDuration:4];
}

许可证

NCSoundHistogram在MIT许可下可用。有关更多信息,请参阅LICENSE文件。