Latest 1.0.2
Homepage https://github.com/anwent/ZHWaveform
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation, AVFoundation, UIKit
Authors

ZHWaveform

ZHWaveform is a library written in Swift, you can easily draw an audio track on iOS, you can customize the slider on both sides, adjust the draw ratio, easy to use.

005_none_ex

02_left_ex

07_center_ex

中文文档

Requirements


  • iOS 8.0+

  • Swift 4.0

Cocoapods


Add the following line to your Podfile:

pod 'ZHWaveform', '~> 1.0.2'

Then, run the following command:

$ pod install

Deserialization


Import

import ZHWaveform

Create

 lazy var waveform: ZHWaveformView = {
    let bundle = Bundle(for: type(of: self)) // music
    let waveform = ZHWaveformView(
        frame: CGRect(x: 0, y: 200, width: view.frame.width, height: 44),
        fileURL: bundle.url(forResource: "Apart", withExtension: "mp3")!
    )
    waveform.croppedDelegate = self
    return waveform
}()

Setting

wavesColor:wavesColor: UIColor

Cut off the beginning part color:beginningPartColor: UIColor

Cut out the end part color:endPartColor: UIColor

Track Scale:trackScale: CGFloat (0 ~ 1)

Delegate

Create start crop,Valid value is the maxX value of the view:

func waveformView(startCropped waveformView: ZHWaveformView) -> UIView?

Create end crop, Valid value is the minX value of the view:

func waveformView(endCropped waveformView: ZHWaveformView) -> UIView?

Start part of the crop current value:

func waveformView(startCropped: UIView, progress rate: CGFloat)

End part of the crop current value:

func waveformView(endCropped: UIView, progress rate: CGFloat)

Latest podspec

{
    "name": "ZHWaveform",
    "version": "1.0.2",
    "summary": "Quickly draw audio volume tracks on iOS, which implement by Swift",
    "description": "Easy to draw audio music tracks, you can drag the slider to select the time",
    "homepage": "https://github.com/anwent/ZHWaveform",
    "license": {
        "type": "MIT",
        "file": "FILE_LICENSE"
    },
    "authors": {
        "zzh": "[email protected]"
    },
    "source": {
        "git": "https://github.com/anwent/ZHWaveform.git",
        "tag": "1.0.2"
    },
    "source_files": "ZHWaveform_Example/ZHWaveform/*.{swift}",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "frameworks": [
        "Foundation",
        "AVFoundation",
        "UIKit"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This