一个可以随意自定义view的弹幕类/A danmaku class that can customize view as your pleases
- 支持完全自定义弹幕
- 支持弹幕的回收
- 支持弹幕速度调整
- 支持自定义弹幕轨道数量
- 支持自定义弹幕间距
- 支持自定义弹幕轨道间距
- 支持不同弹幕样式使用相同/不同轨道
- 支持自动寻找最不拥挤的弹幕轨道
YourClass
/**
创建轨道
@param frame frame
@param trackHeight 轨道高度
@param trackSpeedArray 轨道速度数组
*/
// 弹幕
// 1秒前进ptPerSecond 1fps前进ptPerSecond/COMMENT_VIEW_CONFIG_FPS
CGFloat ptPerSecond = 20.0;
KFFlyCommentView *commentView = [[KFFlyCommentView alloc] initWithFrame:CGRectMake(0, 0, self.width, 0)
trackVerticalMargin:0
trackHeight:30 + 12
trackSpeedArray:@[@(ptPerSecond/COMMENT_VIEW_CONFIG_FPS), @(ptPerSecond/COMMENT_VIEW_CONFIG_FPS)]];
commentView.infinityLoop = YES;
commentView.joinWithLeftEdge = YES;
commentView.dragEnable = YES;
commentView.trackHorizontalPadding = 12;
commentView.y = self.backgroundImageView.maxY - commentView.height - 10;
[self addSubview:commentView];
/**
插入一条弹幕,可以插入任意继承UIView的对象
@param customView 自定义的继承于view(注意,最高不能超过轨道的高,否则会出问题)
@param trackIndex 插入弹幕的轨道(为-1则代表自动寻找最不拥挤的轨道插入)
*/
[commentView appendFlyCommentWithCustomView:customView toTrackIndex:-1];
- (instancetype)initWithFrame:(CGRect)frame
trackVerticalMargin:(CGFloat)trackVerticalMargin
trackHeight:(CGFloat)trackHeight
trackSpeedArray:(NSArray *)trackSpeedArray;
- (void)appendFlyCommentWithCustomView:(UIView *)customView toTrackIndex:(NSInteger)trackIndex;
- (void)stop;
- 邮箱: [email protected]
- QQ:651146554