Skip to content

rsml/PXSiriWave9

 
 

Repository files navigation

PXSiriWave9: Objective-C

PRs Welcome

Getting started

  • Please run below command in your app in order to install cocoapods required by the library:

pod init

pod 'PXSiriWave', '~> 0.0'

Usage

PXSiriWave *siriWave = [[PXSiriWave alloc] initWithFrame: CGRectMake(0, 0, 1000, 1000)];
siriWave.frequency = 1.5;
siriWave.amplitude = 0.01;
siriWave.intensity = 0.3;

siriWave.colors = [NSArray arrayWithObjects: [UIColor brownColor], [UIColor blueColor], [UIColor blackColor], nil];


[siriWave configure];

[self.view addSubview: siriWave];
  • Start Animation

Please setup Timer in order to animate waves:

    
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.10
    target:self
    selector: @selector(targetMethod:)
    userInfo: siriWave
    repeats:YES];
  • Set Timer Target
-(void)targetMethod:(NSTimer *)timer  {
    PXSiriWave *siriWave = [timer userInfo];
    
    [siriWave updateWithLevel: [self _normalizedPowerLevelFromDecibels: .1]];
}

- (CGFloat)_normalizedPowerLevelFromDecibels:(CGFloat)decibels {
    if (decibels < -60.0f || decibels == 0.0f) {
        return 0.0f;
    }
    
    return powf((powf(10.0f, 0.05f * decibels) - powf(10.0f, 0.05f * -60.0f)) * (1.0f / (1.0f - powf(10.0f, 0.05f * -60.0f))), 1.0f / 2.0f);
}
  • Stop Animation
[timer invalidate];
timer = NULL;

Properties

Prop Type Default Note
amplitude number 0.01 Amplitude of Waves
frequency number 1.5 Frequency of Waves
intensity number 0.3 Specify intensity of wave
colors array ["#2085fc", "#5efca9", "#fd4767"] Specify colors of siri wave 9 colors

Credit

Contribution

Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

License

Copyright @ Pranav Raj Singh Chauhan

PXSiriWave is provided under the Apache 2 License.

About

iOS: Siri Waveform effect similar to 9

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 95.1%
  • Ruby 4.9%