Giter Site home page Giter Site logo

kfdanmaku's Introduction

YGFlyCommentManager-Danmaku

一个可以随意自定义view的弹幕类/A danmaku class that can customize view as your pleases

效果

点击查看效果图

特性

  • 支持完全自定义弹幕
  • 支持弹幕的回收
  • 支持弹幕速度调整
  • 支持自定义弹幕轨道数量
  • 支持自定义弹幕间距
  • 支持自定义弹幕轨道间距
  • 支持不同弹幕样式使用相同/不同轨道
  • 支持自动寻找最不拥挤的弹幕轨道

用法

Demo

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;

联系我

kfdanmaku's People

Contributors

zkfpk6 avatar

Stargazers

武夫裴钱 avatar  avatar ZST avatar Zhang SIr avatar 韩博 avatar 王颖博 avatar Wilson avatar 鲜世杰 avatar Zshiren avatar  avatar  avatar 飞鱼 avatar  avatar  avatar  avatar Wales Jiang avatar  avatar  avatar  avatar 石玉龙 avatar MWCao avatar YidaCoder avatar AnnRy avatar Zhiqing avatar  avatar  avatar  avatar xt avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.