SpotlightLyrics 0.1.5

SpotlightLyrics 0.1.5

jayasme维护。



  • 作者
  • jayasme

SpotlightLyrics


CocoaPods Compatible

点击这里查看中文说明

介绍

SpotlightLyrics是一个开源库,帮助开发者解析和显示LRC文件,完全使用Swift 4.2开发,并设计用于iPhone和iPad平台。

Screenshot Screenshot

入门

CocoaPods

pod 'SpotlightLyrics'

手动

  • 下载或克隆仓库,然后编译以获得SpotlightLyrics.framework
  • SpotlightLyrics.framework从框架文件夹复制到您的项目中,
  • 在XCode中打开您的项目,导航到常规 - 链接的框架和库以将组件添加到您的项目中

如何使用

要开始在使用文件中中使用 SpotlightLyrics,只需做以下操作:

import SpotlightLyrics

LyricaParser

如果您只解析 LRC 文件,可以使用 LyricsParser 类,以下是一个示例:

import SpotlightLyrics

// ... Load the LRC string from local or remote

// Pass your lyrics string to create an instance
let parser = LyricsParser(lyrics: lyricsString)

// Now you get everything about the lyrics
print(parser.header.title)
print(parser.header.author)
print(parser.header.album)

for lyric in parser.lyrics {
  print(lyric.text)
  print(lyric.time)
}

LyricsView

SpotlightLyrics 提供了一个类似大多数音乐应用显示歌词并滚动的 LRC 显示组件。

import SpotlightLyrics

// ... Load the LRC string from local or remote

// Create an instance and add it to your UI
let lyricsView = LyricsView()
lyricsView.frame = self.view.bounds
self.view.addSubView(lyricsView)

// Pass the LRC string and style the LyricsView
lyricsView.lyrics = lyricsString
lyricsView.font = UIFont.systemFont(ofSize: 13)
lyricsView.textColor = UIColor.black
lyricsView.highlightedFont = UIFont.systemFont(ofSize: 13)
lyricsView.highlightedTextColor = UIColor.lightGray

// Play
lyricsView.timer.play()

// Pause
lyricsView.timer.pause()

// Seek to an eplased time
lyricsView.timer.seek(toTime: 20.0)

// Start it over
lyricsView.timer.seek(toTime: 0)
lyricsView.timer.play()

请查阅 演示

Stylish

LyricsView 支持以下属性,允许您进行自定义。

属性名称 类型 默认值 描述
lyricTextColor UIColor 浅灰色 未突出显示歌词的颜色
lyricHighlightedTextColor UIColor 黑色 突出显示歌词的颜色
lyricFont UIFont 系统 16 未突出显示歌词的字体
lyricHighlightedFont UIFont 系统 16 加粗 突出显示歌词的字体
lineSpacing CGFloat 16 每行歌词的间距

Objective-C 兼容性

该存储库未在任何方式下在 Objective-C 环境下进行测试。

贡献

任何贡献都欢迎,如果您有任何好主意或遇到任何问题,请提交PR或报告问题。谢谢!

许可协议

MIT授权.