HJDanmaku-Swift 2.0.2

HJDanmaku-Swift 2.0.2

olinone 维护。



  • 作者:
  • panghaijiao

GitHub

HJDanmaku-Swift 是适用于 iOS 的高性能弹幕引擎。更多详情请点击 这里

概览

与 1.0 版本相比,HJDanmaku 2.0 具有更好的性能,例如高性能、大并发和更好的流畅性。当然,您可以根据产品要求自定义单元格样式。在 2.0 版本中,它提供了一种新的实时模式,以满足实时场景。

这里 获取 objc 版本。

特性

  • [性能] 总平均 CPU 使用率低于 5%。
  • [流畅性] 渲染帧率 (FPS) 稳定在 60 帧。
  • [并发性] 转换渲染确保大并发数据的稳定性。

参考

尺寸 1.0 2.0
性能 ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️
流畅性 ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️⭐️
精度 ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️
并发性 ⭐️⭐️ ⭐️⭐️⭐️⭐️⭐️

使用 CocoaPods 安装

CocoaPods 是 Swift 的依赖管理器,可自动简化在项目中使用第三方库的过程。有关详情,请参阅 入门 部分。

Podfile

pod 'HJDanmaku-Swift', '~> 2.0.0'

使用方法

实时模式

// init config with mode HJDanmakuModeLive
let config = HJDanmakuConfiguration.init(danmakuMode: .HJDanmakuModeLive)
self.danmakuView = HJDanmakuView.init(frame: self.view.bounds, configuration: config)

视频模式

// init config with mode HJDanmakuModeVideo
let config = HJDanmakuConfiguration.init(danmakuMode: .HJDanmakuModeVideo)
self.danmakuView = HJDanmakuView.init(frame: self.view.bounds, configuration: config)

发送弹幕

let danmakuModel = DemoDanmakuModel.init(danmakuType: .HJDanmakuTypeLR)
danmakuModel.text = "😊😊olinone.com😊😊"
self.danmakuView.sendDanmaku(danmakuModel, forceRender: true)

自定义样式

// register cell class before dequeue
self.danmakuView.register(DemoDanmakuCell.self, forCellReuseIdentifier: "cell")

// configure cell with custom style
let cell = (danmakuView.dequeueReusableCell(withIdentifier: "cell"))!
let model: DemoDanmakuModel = danmaku as! DemoDanmakuModel
cell.textLabel.font = model.textFont
cell.textLabel.textColor = model.textColor
cell.textLabel.text = model.text

历史发布

HJDanmaku 1.0 首次发布于 2015 年,您可以在文件夹 HJDanmaku1 中找到它。当然,为了更好的性能,我们推荐使用最新版 2.0。

许可证

HJDanmakuDemo 采用 MIT 许可发布。详情请见 LICENSE。著作权 © 2015 olinone。

赞助商

GitHub