HJDanmaku是一个针对iOS的高性能弹幕引擎。有关更多详细信息,请点击此处。
概览
与1.0版本相比,HJDanmaku 2.0具有更好的性能,例如高性能、高并发和更流畅。当然,您可以根据产品需求自定义单元格样式。在2.0版本中,它提供了一个新的实时模式来满足实时场景。
在此处获取Swift版本。
特性
[性能]
总体平均CPU使用率低于5%。[流畅度]
渲染帧率(FPS)保持稳定在60帧。[并发性]
背景渲染确保了大量并发数据的安全性。
参考
尺寸 | 1.0 | 2.0 |
---|---|---|
性能 | ||
流畅度 | ||
准确性 | ||
并发性 |
cocoapods下的安装
CocoaPods 是 Objective-C 的依赖管理器,它自动化并简化了在项目中使用第三方库的过程。有关详细信息,请参阅 开始使用 部分。
Podfile
pod 'HJDanmaku', '~> 2.0'
使用方法
实时模式
// init config with mode HJDanmakuModeLive
HJDanmakuConfiguration *config = [[HJDanmakuConfiguration alloc] initWithDanmakuMode:HJDanmakuModeLive];
HJDanmakuView *danmakuView = [[HJDanmakuView alloc] initWithFrame:self.view.bounds configuration:config];
视频模式
// init config with mode HJDanmakuModeVideo
HJDanmakuConfiguration *config = [[HJDanmakuConfiguration alloc] initWithDanmakuMode:HJDanmakuModeVideo];
HJDanmakuView *danmakuView = [[HJDanmakuView alloc] initWithFrame:self.view.bounds configuration:config];
发送弹幕
DemoDanmakuModel *danmaku = [[DemoDanmakuModel alloc] initWithType:HJDanmakuTypeLR];
danmaku.text = @"😊😊olinone.com😊😊";
[self.danmakuView sendDanmaku:danmaku forceRender:YES];
自定义样式
// register cell class before dequeue
[self.danmakuView registerClass:[DemoDanmakuCell class] forCellReuseIdentifier:@"cell"];
// configure cell with custom style
DemoDanmakuCell *cell = [danmakuView dequeueReusableCellWithIdentifier:@"cell"];
DemoDanmakuModel *model = (DemoDanmakuModel *)danmaku;
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。