Skip to content

Commit 753e8ec

Browse files
committed
Add support for changing waveform colors to example.
1 parent 53b2081 commit 753e8ec

2 files changed

Lines changed: 53 additions & 23 deletions

File tree

Example/Source/Base.lproj/Main.storyboard

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="GzX-4u-840">
3-
<device id="retina4_7" orientation="portrait">
3+
<device id="retina5_5" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
@@ -18,11 +18,11 @@
1818
<viewControllerLayoutGuide type="bottom" id="01F-59-2xz"/>
1919
</layoutGuides>
2020
<view key="view" contentMode="scaleToFill" id="oh1-vd-YBA">
21-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
21+
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
2222
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2323
<subviews>
2424
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ip2-HE-aX1">
25-
<rect key="frame" x="0.0" y="20" width="119.5" height="30"/>
25+
<rect key="frame" x="0.0" y="20" width="132.66666666666666" height="30"/>
2626
<color key="backgroundColor" red="0.98823529409999999" green="0.37647058820000001" blue="0.25882352939999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2727
<state key="normal" title="Load AAC">
2828
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -33,7 +33,7 @@
3333
</connections>
3434
</button>
3535
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="V6O-ov-C15">
36-
<rect key="frame" x="127.5" y="20" width="120" height="30"/>
36+
<rect key="frame" x="140.66666666666669" y="20" width="132.66666666666669" height="30"/>
3737
<color key="backgroundColor" red="0.98823529409999999" green="0.37647058820000001" blue="0.25882352939999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3838
<state key="normal" title="Load MP3">
3939
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -44,7 +44,7 @@
4444
</connections>
4545
</button>
4646
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QiA-5t-Tep">
47-
<rect key="frame" x="255.5" y="20" width="119.5" height="30"/>
47+
<rect key="frame" x="281.33333333333326" y="20" width="132.66666666666669" height="30"/>
4848
<color key="backgroundColor" red="0.98823529409999999" green="0.37647058820000001" blue="0.25882352939999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4949
<state key="normal" title="Load OGG">
5050
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -54,8 +54,35 @@
5454
<action selector="doLoadOGG" destination="GzX-4u-840" eventType="touchUpInside" id="rhB-PI-RJC"/>
5555
</connections>
5656
</button>
57+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WLG-lH-cUv">
58+
<rect key="frame" x="0.0" y="58" width="203.66666666666666" height="30"/>
59+
<color key="backgroundColor" red="0.91658645868301392" green="0.89184486865997314" blue="0.27463445067405701" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
60+
<constraints>
61+
<constraint firstAttribute="height" constant="30" id="7Dv-4V-aqI"/>
62+
</constraints>
63+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
64+
<state key="normal" title="Randomly set play progress">
65+
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
66+
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
67+
</state>
68+
<connections>
69+
<action selector="doAnimation" destination="GzX-4u-840" eventType="touchUpInside" id="fb7-NT-Wds"/>
70+
</connections>
71+
</button>
72+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QDN-fD-Zwd">
73+
<rect key="frame" x="211" y="58" width="203" height="30"/>
74+
<color key="backgroundColor" red="0.9165864587" green="0.89184486870000002" blue="0.27463445069999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
75+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
76+
<state key="normal" title="Randomly set colors">
77+
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
78+
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
79+
</state>
80+
<connections>
81+
<action selector="doChangeColors" destination="GzX-4u-840" eventType="touchUpInside" id="hy5-t9-gRe"/>
82+
</connections>
83+
</button>
5784
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Eo2-dg-ThD">
58-
<rect key="frame" x="0.0" y="96" width="183.5" height="30"/>
85+
<rect key="frame" x="0.0" y="96" width="203" height="30"/>
5986
<color key="backgroundColor" red="0.91658645868301392" green="0.89184486865997314" blue="0.27463445067405701" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6087
<state key="normal" title="Zoom in">
6188
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -66,7 +93,7 @@
6693
</connections>
6794
</button>
6895
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XOT-uC-eqi">
69-
<rect key="frame" x="191.5" y="96" width="183.5" height="30"/>
96+
<rect key="frame" x="211" y="96" width="203" height="30"/>
7097
<color key="backgroundColor" red="0.91658645868301392" green="0.89184486865997314" blue="0.27463445067405701" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
7198
<state key="normal" title="Zoom out">
7299
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -77,7 +104,7 @@
77104
</connections>
78105
</button>
79106
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AIo-Bv-jmO" userLabel="Linear">
80-
<rect key="frame" x="0.0" y="134" width="183.5" height="30"/>
107+
<rect key="frame" x="0.0" y="134" width="203" height="30"/>
81108
<color key="backgroundColor" red="0.9165864587" green="0.89184486870000002" blue="0.27463445069999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
82109
<state key="normal" title="Linear">
83110
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -88,7 +115,7 @@
88115
</connections>
89116
</button>
90117
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="t25-dP-LU3" userLabel="Logarithmic">
91-
<rect key="frame" x="191.5" y="134" width="183.5" height="30"/>
118+
<rect key="frame" x="211" y="134" width="203" height="30"/>
92119
<color key="backgroundColor" red="0.9165864587" green="0.89184486870000002" blue="0.27463445069999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
93120
<state key="normal" title="Logarithmic">
94121
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -98,19 +125,8 @@
98125
<action selector="doLogarithmic" destination="GzX-4u-840" eventType="touchUpInside" id="8C2-de-x46"/>
99126
</connections>
100127
</button>
101-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WLG-lH-cUv">
102-
<rect key="frame" x="0.0" y="58" width="375" height="30"/>
103-
<color key="backgroundColor" red="0.91658645868301392" green="0.89184486865997314" blue="0.27463445067405701" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
104-
<state key="normal" title="Randomly set play progress">
105-
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
106-
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
107-
</state>
108-
<connections>
109-
<action selector="doAnimation" destination="GzX-4u-840" eventType="touchUpInside" id="fb7-NT-Wds"/>
110-
</connections>
111-
</button>
112128
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="C2Y-UB-xTc">
113-
<rect key="frame" x="0.0" y="172" width="375" height="30"/>
129+
<rect key="frame" x="0.0" y="172" width="414" height="30"/>
114130
<color key="backgroundColor" red="0.91658645868301392" green="0.89184486865997314" blue="0.27463445067405701" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
115131
<state key="normal" title="Run performance profiling">
116132
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -121,7 +137,7 @@
121137
</connections>
122138
</button>
123139
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pHr-84-A7W" customClass="FDWaveformView" customModule="FDWaveformView">
124-
<rect key="frame" x="0.0" y="210" width="375" height="457"/>
140+
<rect key="frame" x="0.0" y="210" width="414" height="526"/>
125141
<color key="backgroundColor" red="0.99811935424804688" green="0.92034381628036499" blue="0.90713727474212646" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
126142
<userDefinedRuntimeAttributes>
127143
<userDefinedRuntimeAttribute type="color" keyPath="wavesColor">
@@ -139,19 +155,22 @@
139155
<constraint firstItem="AIo-Bv-jmO" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="9KE-Xv-0oY"/>
140156
<constraint firstItem="t25-dP-LU3" firstAttribute="top" secondItem="AIo-Bv-jmO" secondAttribute="top" id="BMs-8H-mOR"/>
141157
<constraint firstItem="QiA-5t-Tep" firstAttribute="top" secondItem="Ip2-HE-aX1" secondAttribute="top" id="EP2-Bz-Vr6"/>
142-
<constraint firstAttribute="trailing" secondItem="WLG-lH-cUv" secondAttribute="trailing" id="HHp-cp-GGI"/>
143158
<constraint firstItem="C2Y-UB-xTc" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="HpT-w6-iSA"/>
144159
<constraint firstItem="Eo2-dg-ThD" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="Kke-ES-oXY"/>
145160
<constraint firstItem="Eo2-dg-ThD" firstAttribute="width" secondItem="XOT-uC-eqi" secondAttribute="width" id="LBw-T0-4UD"/>
146161
<constraint firstItem="QiA-5t-Tep" firstAttribute="width" secondItem="Ip2-HE-aX1" secondAttribute="width" id="LWw-hq-qY8"/>
147162
<constraint firstItem="pHr-84-A7W" firstAttribute="top" secondItem="C2Y-UB-xTc" secondAttribute="bottom" constant="8" id="Npi-VG-9Hy"/>
148163
<constraint firstItem="V6O-ov-C15" firstAttribute="leading" secondItem="Ip2-HE-aX1" secondAttribute="trailing" constant="8" id="OPB-Vh-njT"/>
164+
<constraint firstAttribute="trailing" secondItem="QDN-fD-Zwd" secondAttribute="trailing" id="QTd-XL-REq"/>
149165
<constraint firstItem="Eo2-dg-ThD" firstAttribute="top" secondItem="WLG-lH-cUv" secondAttribute="bottom" constant="8" id="SQN-bP-TFX"/>
166+
<constraint firstItem="QDN-fD-Zwd" firstAttribute="leading" secondItem="WLG-lH-cUv" secondAttribute="trailing" constant="8" id="SmM-To-9dW"/>
150167
<constraint firstItem="AIo-Bv-jmO" firstAttribute="width" secondItem="t25-dP-LU3" secondAttribute="width" id="TpO-pG-ZgS"/>
151168
<constraint firstItem="XOT-uC-eqi" firstAttribute="top" secondItem="Eo2-dg-ThD" secondAttribute="top" id="UYM-th-ZWm"/>
169+
<constraint firstItem="WLG-lH-cUv" firstAttribute="height" secondItem="QDN-fD-Zwd" secondAttribute="height" id="V1j-L5-9JC"/>
152170
<constraint firstItem="01F-59-2xz" firstAttribute="top" secondItem="pHr-84-A7W" secondAttribute="bottom" id="VQx-0k-2h0"/>
153171
<constraint firstAttribute="trailing" secondItem="t25-dP-LU3" secondAttribute="trailing" id="XcT-QX-Vg4"/>
154172
<constraint firstItem="pHr-84-A7W" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="ZNn-L4-LJb"/>
173+
<constraint firstItem="QDN-fD-Zwd" firstAttribute="width" secondItem="WLG-lH-cUv" secondAttribute="width" id="cfr-Vg-qXg"/>
155174
<constraint firstItem="WLG-lH-cUv" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="g3y-aI-M8l"/>
156175
<constraint firstItem="C2Y-UB-xTc" firstAttribute="top" secondItem="AIo-Bv-jmO" secondAttribute="bottom" constant="8" id="gW5-tE-o5r"/>
157176
<constraint firstItem="QiA-5t-Tep" firstAttribute="leading" secondItem="V6O-ov-C15" secondAttribute="trailing" constant="8" id="hUB-FB-37u"/>
@@ -162,6 +181,7 @@
162181
<constraint firstItem="QiA-5t-Tep" firstAttribute="width" secondItem="V6O-ov-C15" secondAttribute="width" id="lII-fH-R24"/>
163182
<constraint firstItem="t25-dP-LU3" firstAttribute="leading" secondItem="AIo-Bv-jmO" secondAttribute="trailing" constant="8" id="lPo-HC-P0r"/>
164183
<constraint firstItem="Ip2-HE-aX1" firstAttribute="leading" secondItem="oh1-vd-YBA" secondAttribute="leading" id="oQN-9n-qZO"/>
184+
<constraint firstItem="QDN-fD-Zwd" firstAttribute="top" secondItem="WLG-lH-cUv" secondAttribute="top" id="qhO-6Z-Krt"/>
165185
<constraint firstItem="AIo-Bv-jmO" firstAttribute="top" secondItem="Eo2-dg-ThD" secondAttribute="bottom" constant="8" id="y5V-dz-TNg"/>
166186
</constraints>
167187
</view>
@@ -172,6 +192,7 @@
172192
</viewController>
173193
<placeholder placeholderIdentifier="IBFirstResponder" id="5tX-dp-6bC" sceneMemberID="firstResponder"/>
174194
</objects>
195+
<point key="canvasLocation" x="136.80000000000001" y="138.98050974512745"/>
175196
</scene>
176197
</scenes>
177198
</document>

Example/Source/ViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ class ViewController: UIViewController {
9595
self.waveform.waveformType = .logarithmic
9696
}
9797

98+
@IBAction func doChangeColors() {
99+
let randomColor: () -> (UIColor) = {
100+
return UIColor(red: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1)
101+
}
102+
103+
self.waveform.wavesColor = randomColor()
104+
self.waveform.progressColor = randomColor()
105+
}
106+
98107
override func viewDidLoad() {
99108
super.viewDidLoad()
100109
let thisBundle = Bundle(for: type(of: self))

0 commit comments

Comments
 (0)