├── .DS_Store ├── DLMusicWaveViewDemo ├── DLMusicWaveViewDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── user.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── user.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist └── DLMusicWaveViewDemo │ ├── .DS_Store │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── capture_icon_djs.imageset │ │ ├── Contents.json │ │ ├── capture_icon_djs@2x.png │ │ └── capture_icon_djs@3x.png │ ├── capture_jyy.imageset │ │ ├── Contents.json │ │ ├── capture_jyy@2x.png │ │ └── capture_jyy@3x.png │ ├── capture_jyy2.imageset │ │ ├── Contents.json │ │ ├── capture_jyy2@2x.png │ │ └── capture_jyy2@3x.png │ └── capture_jyy3.imageset │ │ ├── Contents.json │ │ ├── capture_jyy3@2x.png │ │ └── capture_jyy3@3x.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── DLMusicWaveView │ └── DLMusicWaveView.swift │ ├── Info.plist │ └── ViewController.swift ├── Gif └── IMG_2387.GIF ├── LICENSE └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/.DS_Store -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CE16E488230E7E4C00D6E7ED /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE16E487230E7E4C00D6E7ED /* AppDelegate.swift */; }; 11 | CE16E48A230E7E4C00D6E7ED /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE16E489230E7E4C00D6E7ED /* ViewController.swift */; }; 12 | CE16E48D230E7E4C00D6E7ED /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE16E48B230E7E4C00D6E7ED /* Main.storyboard */; }; 13 | CE16E48F230E7E4D00D6E7ED /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE16E48E230E7E4D00D6E7ED /* Assets.xcassets */; }; 14 | CE16E492230E7E4D00D6E7ED /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE16E490230E7E4D00D6E7ED /* LaunchScreen.storyboard */; }; 15 | CE16E49B230E7E9700D6E7ED /* DLMusicWaveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE16E49A230E7E9700D6E7ED /* DLMusicWaveView.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | CE16E484230E7E4C00D6E7ED /* DLMusicWaveViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DLMusicWaveViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | CE16E487230E7E4C00D6E7ED /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | CE16E489230E7E4C00D6E7ED /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | CE16E48C230E7E4C00D6E7ED /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | CE16E48E230E7E4D00D6E7ED /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | CE16E491230E7E4D00D6E7ED /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | CE16E493230E7E4D00D6E7ED /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | CE16E49A230E7E9700D6E7ED /* DLMusicWaveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLMusicWaveView.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | CE16E481230E7E4C00D6E7ED /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | CE16E47B230E7E4C00D6E7ED = { 41 | isa = PBXGroup; 42 | children = ( 43 | CE16E486230E7E4C00D6E7ED /* DLMusicWaveViewDemo */, 44 | CE16E485230E7E4C00D6E7ED /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | CE16E485230E7E4C00D6E7ED /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | CE16E484230E7E4C00D6E7ED /* DLMusicWaveViewDemo.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | CE16E486230E7E4C00D6E7ED /* DLMusicWaveViewDemo */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | CE16E499230E7E6900D6E7ED /* DLMusicWaveView */, 60 | CE16E487230E7E4C00D6E7ED /* AppDelegate.swift */, 61 | CE16E489230E7E4C00D6E7ED /* ViewController.swift */, 62 | CE16E48B230E7E4C00D6E7ED /* Main.storyboard */, 63 | CE16E48E230E7E4D00D6E7ED /* Assets.xcassets */, 64 | CE16E490230E7E4D00D6E7ED /* LaunchScreen.storyboard */, 65 | CE16E493230E7E4D00D6E7ED /* Info.plist */, 66 | ); 67 | path = DLMusicWaveViewDemo; 68 | sourceTree = ""; 69 | }; 70 | CE16E499230E7E6900D6E7ED /* DLMusicWaveView */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | CE16E49A230E7E9700D6E7ED /* DLMusicWaveView.swift */, 74 | ); 75 | path = DLMusicWaveView; 76 | sourceTree = ""; 77 | }; 78 | /* End PBXGroup section */ 79 | 80 | /* Begin PBXNativeTarget section */ 81 | CE16E483230E7E4C00D6E7ED /* DLMusicWaveViewDemo */ = { 82 | isa = PBXNativeTarget; 83 | buildConfigurationList = CE16E496230E7E4D00D6E7ED /* Build configuration list for PBXNativeTarget "DLMusicWaveViewDemo" */; 84 | buildPhases = ( 85 | CE16E480230E7E4C00D6E7ED /* Sources */, 86 | CE16E481230E7E4C00D6E7ED /* Frameworks */, 87 | CE16E482230E7E4C00D6E7ED /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = DLMusicWaveViewDemo; 94 | productName = DLMusicWaveViewDemo; 95 | productReference = CE16E484230E7E4C00D6E7ED /* DLMusicWaveViewDemo.app */; 96 | productType = "com.apple.product-type.application"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | CE16E47C230E7E4C00D6E7ED /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | LastSwiftUpdateCheck = 1020; 105 | LastUpgradeCheck = 1020; 106 | ORGANIZATIONNAME = muyang; 107 | TargetAttributes = { 108 | CE16E483230E7E4C00D6E7ED = { 109 | CreatedOnToolsVersion = 10.2.1; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = CE16E47F230E7E4C00D6E7ED /* Build configuration list for PBXProject "DLMusicWaveViewDemo" */; 114 | compatibilityVersion = "Xcode 9.3"; 115 | developmentRegion = en; 116 | hasScannedForEncodings = 0; 117 | knownRegions = ( 118 | en, 119 | Base, 120 | ); 121 | mainGroup = CE16E47B230E7E4C00D6E7ED; 122 | productRefGroup = CE16E485230E7E4C00D6E7ED /* Products */; 123 | projectDirPath = ""; 124 | projectRoot = ""; 125 | targets = ( 126 | CE16E483230E7E4C00D6E7ED /* DLMusicWaveViewDemo */, 127 | ); 128 | }; 129 | /* End PBXProject section */ 130 | 131 | /* Begin PBXResourcesBuildPhase section */ 132 | CE16E482230E7E4C00D6E7ED /* Resources */ = { 133 | isa = PBXResourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | CE16E492230E7E4D00D6E7ED /* LaunchScreen.storyboard in Resources */, 137 | CE16E48F230E7E4D00D6E7ED /* Assets.xcassets in Resources */, 138 | CE16E48D230E7E4C00D6E7ED /* Main.storyboard in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | CE16E480230E7E4C00D6E7ED /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | CE16E49B230E7E9700D6E7ED /* DLMusicWaveView.swift in Sources */, 150 | CE16E48A230E7E4C00D6E7ED /* ViewController.swift in Sources */, 151 | CE16E488230E7E4C00D6E7ED /* AppDelegate.swift in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin PBXVariantGroup section */ 158 | CE16E48B230E7E4C00D6E7ED /* Main.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | CE16E48C230E7E4C00D6E7ED /* Base */, 162 | ); 163 | name = Main.storyboard; 164 | sourceTree = ""; 165 | }; 166 | CE16E490230E7E4D00D6E7ED /* LaunchScreen.storyboard */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | CE16E491230E7E4D00D6E7ED /* Base */, 170 | ); 171 | name = LaunchScreen.storyboard; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXVariantGroup section */ 175 | 176 | /* Begin XCBuildConfiguration section */ 177 | CE16E494230E7E4D00D6E7ED /* Debug */ = { 178 | isa = XCBuildConfiguration; 179 | buildSettings = { 180 | ALWAYS_SEARCH_USER_PATHS = NO; 181 | CLANG_ANALYZER_NONNULL = YES; 182 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 183 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 184 | CLANG_CXX_LIBRARY = "libc++"; 185 | CLANG_ENABLE_MODULES = YES; 186 | CLANG_ENABLE_OBJC_ARC = YES; 187 | CLANG_ENABLE_OBJC_WEAK = YES; 188 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_COMMA = YES; 191 | CLANG_WARN_CONSTANT_CONVERSION = YES; 192 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INFINITE_RECURSION = YES; 198 | CLANG_WARN_INT_CONVERSION = YES; 199 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 201 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 204 | CLANG_WARN_STRICT_PROTOTYPES = YES; 205 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 206 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 207 | CLANG_WARN_UNREACHABLE_CODE = YES; 208 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 209 | CODE_SIGN_IDENTITY = "iPhone Developer"; 210 | COPY_PHASE_STRIP = NO; 211 | DEBUG_INFORMATION_FORMAT = dwarf; 212 | ENABLE_STRICT_OBJC_MSGSEND = YES; 213 | ENABLE_TESTABILITY = YES; 214 | GCC_C_LANGUAGE_STANDARD = gnu11; 215 | GCC_DYNAMIC_NO_PIC = NO; 216 | GCC_NO_COMMON_BLOCKS = YES; 217 | GCC_OPTIMIZATION_LEVEL = 0; 218 | GCC_PREPROCESSOR_DEFINITIONS = ( 219 | "DEBUG=1", 220 | "$(inherited)", 221 | ); 222 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 223 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 224 | GCC_WARN_UNDECLARED_SELECTOR = YES; 225 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 226 | GCC_WARN_UNUSED_FUNCTION = YES; 227 | GCC_WARN_UNUSED_VARIABLE = YES; 228 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 229 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 230 | MTL_FAST_MATH = YES; 231 | ONLY_ACTIVE_ARCH = YES; 232 | SDKROOT = iphoneos; 233 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 234 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 235 | }; 236 | name = Debug; 237 | }; 238 | CE16E495230E7E4D00D6E7ED /* Release */ = { 239 | isa = XCBuildConfiguration; 240 | buildSettings = { 241 | ALWAYS_SEARCH_USER_PATHS = NO; 242 | CLANG_ANALYZER_NONNULL = YES; 243 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 244 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 245 | CLANG_CXX_LIBRARY = "libc++"; 246 | CLANG_ENABLE_MODULES = YES; 247 | CLANG_ENABLE_OBJC_ARC = YES; 248 | CLANG_ENABLE_OBJC_WEAK = YES; 249 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 250 | CLANG_WARN_BOOL_CONVERSION = YES; 251 | CLANG_WARN_COMMA = YES; 252 | CLANG_WARN_CONSTANT_CONVERSION = YES; 253 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 254 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 255 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 256 | CLANG_WARN_EMPTY_BODY = YES; 257 | CLANG_WARN_ENUM_CONVERSION = YES; 258 | CLANG_WARN_INFINITE_RECURSION = YES; 259 | CLANG_WARN_INT_CONVERSION = YES; 260 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 261 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 262 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 263 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 264 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 265 | CLANG_WARN_STRICT_PROTOTYPES = YES; 266 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 267 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | CODE_SIGN_IDENTITY = "iPhone Developer"; 271 | COPY_PHASE_STRIP = NO; 272 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 273 | ENABLE_NS_ASSERTIONS = NO; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | GCC_C_LANGUAGE_STANDARD = gnu11; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 284 | MTL_ENABLE_DEBUG_INFO = NO; 285 | MTL_FAST_MATH = YES; 286 | SDKROOT = iphoneos; 287 | SWIFT_COMPILATION_MODE = wholemodule; 288 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 289 | VALIDATE_PRODUCT = YES; 290 | }; 291 | name = Release; 292 | }; 293 | CE16E497230E7E4D00D6E7ED /* Debug */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | CODE_SIGN_STYLE = Automatic; 298 | DEVELOPMENT_TEAM = 3P9NR4LP44; 299 | INFOPLIST_FILE = DLMusicWaveViewDemo/Info.plist; 300 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 301 | LD_RUNPATH_SEARCH_PATHS = ( 302 | "$(inherited)", 303 | "@executable_path/Frameworks", 304 | ); 305 | PRODUCT_BUNDLE_IDENTIFIER = com.muyang.DLMusicWaveViewDemo; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | SWIFT_VERSION = 5.0; 308 | TARGETED_DEVICE_FAMILY = "1,2"; 309 | }; 310 | name = Debug; 311 | }; 312 | CE16E498230E7E4D00D6E7ED /* Release */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 316 | CODE_SIGN_STYLE = Automatic; 317 | DEVELOPMENT_TEAM = 3P9NR4LP44; 318 | INFOPLIST_FILE = DLMusicWaveViewDemo/Info.plist; 319 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 320 | LD_RUNPATH_SEARCH_PATHS = ( 321 | "$(inherited)", 322 | "@executable_path/Frameworks", 323 | ); 324 | PRODUCT_BUNDLE_IDENTIFIER = com.muyang.DLMusicWaveViewDemo; 325 | PRODUCT_NAME = "$(TARGET_NAME)"; 326 | SWIFT_VERSION = 5.0; 327 | TARGETED_DEVICE_FAMILY = "1,2"; 328 | }; 329 | name = Release; 330 | }; 331 | /* End XCBuildConfiguration section */ 332 | 333 | /* Begin XCConfigurationList section */ 334 | CE16E47F230E7E4C00D6E7ED /* Build configuration list for PBXProject "DLMusicWaveViewDemo" */ = { 335 | isa = XCConfigurationList; 336 | buildConfigurations = ( 337 | CE16E494230E7E4D00D6E7ED /* Debug */, 338 | CE16E495230E7E4D00D6E7ED /* Release */, 339 | ); 340 | defaultConfigurationIsVisible = 0; 341 | defaultConfigurationName = Release; 342 | }; 343 | CE16E496230E7E4D00D6E7ED /* Build configuration list for PBXNativeTarget "DLMusicWaveViewDemo" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | CE16E497230E7E4D00D6E7ED /* Debug */, 347 | CE16E498230E7E4D00D6E7ED /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | /* End XCConfigurationList section */ 353 | }; 354 | rootObject = CE16E47C230E7E4C00D6E7ED /* Project object */; 355 | } 356 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DLMusicWaveViewDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/.DS_Store -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DLMusicWaveViewDemo 4 | // 5 | // Created by user on 2019/8/22. 6 | // Copyright © 2019 muyang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_icon_djs.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "capture_icon_djs@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "capture_icon_djs@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_icon_djs.imageset/capture_icon_djs@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_icon_djs.imageset/capture_icon_djs@2x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_icon_djs.imageset/capture_icon_djs@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_icon_djs.imageset/capture_icon_djs@3x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "capture_jyy@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "capture_jyy@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy.imageset/capture_jyy@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy.imageset/capture_jyy@2x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy.imageset/capture_jyy@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy.imageset/capture_jyy@3x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "capture_jyy2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "capture_jyy2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy2.imageset/capture_jyy2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy2.imageset/capture_jyy2@2x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy2.imageset/capture_jyy2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy2.imageset/capture_jyy2@3x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "capture_jyy3@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "capture_jyy3@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy3.imageset/capture_jyy3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy3.imageset/capture_jyy3@2x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy3.imageset/capture_jyy3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/DLMusicWaveViewDemo/DLMusicWaveViewDemo/Assets.xcassets/capture_jyy3.imageset/capture_jyy3@3x.png -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/DLMusicWaveView/DLMusicWaveView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLMusicWaveView.swift 3 | // DLMusicWaveViewDemo 4 | // 5 | // Created by user on 2019/8/22. 6 | // Copyright © 2019 muyang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class DLMusicWaveView: UIView { 12 | static let screenWidth: CGFloat = UIScreen.main.bounds.size.width 13 | 14 | /// 音乐总时长 15 | open var musicDuration: CGFloat = 180 { 16 | didSet { 17 | durationLabel.text = String(format: "%02d:%02d", arguments: [Int(oldValue) / 60, Int(oldValue) % 60]) 18 | } 19 | } 20 | /// 音乐裁剪时长 21 | open var musicCutPart: CGFloat = 15 { 22 | willSet { 23 | partLabel.text = "支持裁剪\(Int(newValue))秒" 24 | var frame = redBgMusicMaskLayer.frame 25 | frame.size.width = musicDurationToViewWidth(newValue) 26 | redBgMusicMaskLayer.frame = frame 27 | } 28 | } 29 | /// 音乐开始位置 30 | open var musicStartTime: CGFloat = 0 { 31 | willSet { 32 | sliderLabel.text = String(format: "%02d:%02d", arguments: [Int(newValue) / 60, Int(newValue) % 60]) 33 | let pointX = newValue / musicDuration * sliderContentView.bounds.size.width 34 | /// 修改滑竿位置 35 | var sliderMoveFrame = sliderMoveView.frame 36 | sliderMoveFrame.origin.x = pointX - 3 + 10 37 | sliderMoveView.frame = sliderMoveFrame 38 | /// 修改滑竿label位置 39 | var sliderLabelFrame = sliderLabel.frame 40 | sliderLabelFrame.origin.x = pointX + 3 - 15 + 10 41 | sliderLabel.frame = sliderLabelFrame 42 | /// 修改红色位置 43 | var redFrame = redBgMusicMaskLayer.frame 44 | redFrame.origin.x = pointX 45 | redBgMusicMaskLayer.frame = redFrame 46 | /// 修改红色位置 47 | var blueFrame = blueBgMusicMaskLayer.frame 48 | blueFrame.origin.x = pointX 49 | blueBgMusicMaskLayer.frame = blueFrame 50 | } 51 | } 52 | 53 | /// 开始位置label 54 | private var startLabel: UILabel = { 55 | let label = UILabel.init(frame: CGRect.zero) 56 | label.text = "00:00" 57 | label.font = UIFont(name: "PingFangSC-Regular", size: 10) 58 | label.textColor = UIColor(red: 0.98, green: 0.98, blue: 0.98, alpha: 0.5) 59 | label.textAlignment = .left 60 | return label 61 | }() 62 | /// 滑动位置label 63 | private var sliderLabel: UILabel = { 64 | let label = UILabel.init(frame: CGRect.zero) 65 | label.text = "00:00" 66 | label.font = UIFont(name: "PingFangSC-Regular", size: 10) 67 | label.textColor = UIColor(red: 0.69, green: 1, blue: 0.25, alpha: 1) 68 | label.textAlignment = .left 69 | return label 70 | }() 71 | /// 结束位置label 72 | private var durationLabel: UILabel = { 73 | let label = UILabel.init(frame: CGRect.zero) 74 | label.text = "03:00" 75 | label.font = UIFont(name: "PingFangSC-Regular", size: 10) 76 | label.textColor = UIColor(red: 0.98, green: 0.98, blue: 0.98, alpha: 0.5) 77 | label.textAlignment = .right 78 | return label 79 | }() 80 | /// 结束位置label 81 | private var partLabel: UILabel = { 82 | let label = UILabel.init(frame: CGRect.zero) 83 | label.text = "支持裁剪15秒" 84 | label.font = UIFont(name: "PingFangSC-Regular", size: 10) 85 | label.textColor = UIColor(red: 0.98, green: 0.98, blue: 0.98, alpha: 0.5) 86 | label.textAlignment = .center 87 | return label 88 | }() 89 | /// 滑动区域 90 | private var sliderContentView: UIView = { 91 | let view = UIView.init(frame: CGRect.zero) 92 | view.backgroundColor = UIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 1) 93 | view.layer.cornerRadius = 5 94 | view.layer.masksToBounds = true 95 | return view 96 | }() 97 | /// 灰色背景 98 | private var grayBgMusicImageView: UIImageView = { 99 | let view = UIImageView(frame: CGRect.zero) 100 | let image1 = UIImage(named: "capture_jyy", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil)! 101 | view.backgroundColor = UIColor(patternImage: image1) 102 | return view 103 | }() 104 | /// 红色背景 105 | private var redBgMusicImageView: UIImageView = { 106 | let view = UIImageView(frame: CGRect.zero) 107 | let image1 = UIImage(named: "capture_jyy2", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil)! 108 | view.backgroundColor = UIColor(patternImage: image1) 109 | return view 110 | }() 111 | /// 红色遮罩 112 | private var redBgMusicMaskLayer: CALayer = { 113 | let layer = CALayer.init() 114 | layer.contents = UIImage(named: "capture_jyy2", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil)?.cgImage 115 | layer.contentsGravity = CALayerContentsGravity.resizeAspect 116 | layer.backgroundColor = UIColor.white.cgColor 117 | return layer 118 | }() 119 | /// 蓝色背景 120 | private var blueBgMusicImageView: UIImageView = { 121 | let view = UIImageView(frame: CGRect.zero) 122 | let image1 = UIImage(named: "capture_jyy3", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil)! 123 | view.backgroundColor = UIColor(patternImage: image1) 124 | return view 125 | }() 126 | /// 蓝色遮罩 127 | private var blueBgMusicMaskLayer: CALayer = { 128 | let layer = CALayer.init() 129 | layer.contents = UIImage(named: "capture_jyy3", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil)?.cgImage 130 | layer.contentsGravity = CALayerContentsGravity.resizeAspect 131 | layer.backgroundColor = UIColor.white.cgColor 132 | return layer 133 | }() 134 | /// 滑竿 135 | private var sliderMoveView: UIImageView = { 136 | let view = UIImageView.init(frame: CGRect.zero) 137 | view.image = UIImage(named: "capture_icon_djs", in: Bundle(for: DLMusicWaveView.self), compatibleWith: nil) 138 | return view 139 | }() 140 | /// 滑动标识 141 | private var panGestureBegin: Bool = false 142 | /// 进度 143 | private var progressTimer: Timer? 144 | private var progressDuration: CGFloat = 0 145 | 146 | override init(frame: CGRect) { 147 | super.init(frame: frame) 148 | self.backgroundColor = UIColor.black.withAlphaComponent(0.8) 149 | 150 | self.setupUI() 151 | self.addGesture() 152 | self.startAnimation() 153 | } 154 | 155 | private func setupUI() { 156 | startLabel.frame = CGRect.init(x: 10, y: 80, width: 30, height: 20) 157 | self.addSubview(startLabel) 158 | 159 | sliderLabel.frame = CGRect.init(x: 0, y: 0, width: 30, height: 20) 160 | self.addSubview(sliderLabel) 161 | 162 | partLabel.frame = CGRect.init(x: self.bounds.size.width / 2 - 50, y: 80, width: 100, height: 20) 163 | self.addSubview(partLabel) 164 | 165 | durationLabel.frame = CGRect.init(x: self.bounds.size.width - 40, y: 80, width: 30, height: 20) 166 | self.addSubview(durationLabel) 167 | 168 | sliderContentView.frame = CGRect.init(x: 10, y: 20, width: self.bounds.size.width - 20, height: 60) 169 | self.addSubview(sliderContentView) 170 | // 灰色底图 171 | grayBgMusicImageView.frame = CGRect.init(x: 0, y: 10, width: sliderContentView.bounds.size.width, height: sliderContentView.bounds.size.height - 20) 172 | sliderContentView.addSubview(grayBgMusicImageView) 173 | // 红色底图 174 | redBgMusicImageView.frame = CGRect.init(x: 0, y: 10, width: sliderContentView.bounds.size.width, height: sliderContentView.bounds.size.height - 20) 175 | sliderContentView.addSubview(redBgMusicImageView) 176 | redBgMusicMaskLayer.frame = CGRect.init(x: 0, y: 0, width: musicDurationToViewWidth(musicCutPart), height: redBgMusicImageView.bounds.size.height) 177 | redBgMusicImageView.layer.mask = redBgMusicMaskLayer 178 | // 蓝色底图 179 | blueBgMusicImageView.frame = CGRect.init(x: 0, y: 10, width: sliderContentView.bounds.size.width, height: sliderContentView.bounds.size.height - 20) 180 | sliderContentView.addSubview(blueBgMusicImageView) 181 | blueBgMusicMaskLayer.frame = CGRect.init(x: 0, y: 0, width: 0, height: redBgMusicImageView.bounds.size.height) 182 | blueBgMusicImageView.layer.mask = blueBgMusicMaskLayer 183 | 184 | sliderMoveView.frame = CGRect(x: 10 - 2, y: 20, width: 6, height: 60) 185 | self.addSubview(sliderMoveView) 186 | } 187 | 188 | private func addGesture() { 189 | let pan = UIPanGestureRecognizer.init(target: self, action: #selector(panGestureAction(_:))) 190 | sliderContentView.addGestureRecognizer(pan) 191 | } 192 | 193 | @objc private func panGestureAction(_ ges: UIPanGestureRecognizer) { 194 | let panPoint = ges.location(in: ges.view) 195 | if ges.state == .began { 196 | let biggerFrame = CGRect.init(x: sliderMoveView.frame.origin.x - 10, y: 0, width: sliderMoveView.bounds.size.width + 10, height: sliderMoveView.bounds.size.height) 197 | if biggerFrame.contains(panPoint) { 198 | self.clearTimer() 199 | self.panGestureBegin = true 200 | } else { 201 | self.panGestureBegin = false 202 | } 203 | } else if ges.state == .changed { 204 | if self.panGestureBegin == true { 205 | self.changeStartLocation(panPoint) 206 | } 207 | } else if ges.state == .ended { 208 | if self.panGestureBegin == true { 209 | self.startAnimation() 210 | } 211 | self.panGestureBegin = false 212 | } 213 | } 214 | 215 | private func changeStartLocation(_ point: CGPoint) { 216 | var locationX: CGFloat = point.x 217 | if locationX < 10 { 218 | locationX = 10 219 | } 220 | let partWidth = musicDurationToViewWidth(musicCutPart) 221 | let maxLocation = self.bounds.size.width - 10 - partWidth 222 | if locationX > maxLocation { 223 | locationX = maxLocation 224 | } 225 | /// 修改音乐其实位置 226 | self.musicStartTime = ((locationX - 10) / sliderContentView.bounds.size.width) * musicDuration 227 | } 228 | 229 | private func musicDurationToViewWidth(_ duration: CGFloat) -> CGFloat { 230 | return duration / musicDuration * sliderContentView.bounds.size.width 231 | } 232 | 233 | private func startAnimation() { 234 | clearTimer() 235 | progressTimer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true) 236 | } 237 | 238 | @objc private func updateProgress() { 239 | progressDuration += 0.5 240 | if progressDuration > musicCutPart { 241 | progressDuration = 0 242 | } 243 | var frame = blueBgMusicMaskLayer.frame 244 | frame.size.width = musicDurationToViewWidth(progressDuration) 245 | blueBgMusicMaskLayer.frame = frame 246 | } 247 | 248 | private func clearTimer() { 249 | progressTimer?.invalidate() 250 | progressTimer = nil 251 | progressDuration = 0 252 | var frame = blueBgMusicMaskLayer.frame 253 | frame.size.width = 0 254 | blueBgMusicMaskLayer.frame = frame 255 | } 256 | 257 | required init?(coder aDecoder: NSCoder) { 258 | fatalError("init(coder:) has not been implemented") 259 | } 260 | 261 | deinit { 262 | clearTimer() 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DLMusicWaveViewDemo/DLMusicWaveViewDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DLMusicWaveViewDemo 4 | // 5 | // Created by user on 2019/8/22. 6 | // Copyright © 2019 muyang. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view. 16 | // view.backgroundColor = UIColor.lightGray 17 | 18 | let musicWaveView = DLMusicWaveView.init(frame: CGRect.init(x: 0, y: 200, width: UIScreen.main.bounds.size.width, height: 100)) 19 | view.addSubview(musicWaveView) 20 | } 21 | 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Gif/IMG_2387.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LwqDeveloper/DLMusicWaveView/48b689587e98f5afef1eebe516304ff781485353/Gif/IMG_2387.GIF -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 李韦琼 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DLMusicWaveView 2 | 仿抖音 音乐片段截取显示 3 | 4 | # 效果图 5 | ![裁剪音乐图](https://github.com/LwqDeveloper/DLMusicWaveView/blob/master/Gif/IMG_2387.GIF) 6 | --------------------------------------------------------------------------------