@@ -13,6 +13,8 @@ import FDWaveformView
1313class ViewController : UIViewController {
1414 @IBOutlet weak var waveform : FDWaveformView !
1515 @IBOutlet var playButton : UIView !
16+ @IBOutlet weak var logarithmicButton : UIButton !
17+ @IBOutlet weak var linearButton : UIButton !
1618
1719 fileprivate var startRendering = Date ( )
1820 fileprivate var endRendering = Date ( )
@@ -89,10 +91,12 @@ class ViewController: UIViewController {
8991
9092 @IBAction func doLinear( ) {
9193 self . waveform. waveformType = . linear
94+ updateWaveformTypeButtons ( )
9295 }
9396
9497 @IBAction func doLogarithmic( ) {
9598 self . waveform. waveformType = . logarithmic
99+ updateWaveformTypeButtons ( )
96100 }
97101
98102 @IBAction func doChangeColors( ) {
@@ -116,6 +120,19 @@ class ViewController: UIViewController {
116120 self . waveform. doesAllowScrubbing = true
117121 self . waveform. doesAllowStretch = true
118122 self . waveform. doesAllowScroll = true
123+ updateWaveformTypeButtons ( )
124+ }
125+
126+ func updateWaveformTypeButtons( ) {
127+ let ( selectedButton, nonSelectedButton) : ( UIButton , UIButton ) = {
128+ switch self . waveform. waveformType {
129+ case . linear: return ( self . linearButton, self . logarithmicButton)
130+ case . logarithmic: return ( self . logarithmicButton, self . linearButton)
131+ }
132+ } ( )
133+ selectedButton. layer. borderColor = #colorLiteral( red: 0 , green: 0 , blue: 0 , alpha: 0.25 ) . cgColor
134+ selectedButton. layer. borderWidth = 2
135+ nonSelectedButton. layer. borderWidth = 0
119136 }
120137}
121138
0 commit comments