• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

KYBarrageKit: This is a barrage of rendering library iOS high expansion, for mos ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

KYBarrageKit

开源软件地址:

https://gitee.com/kingly09/KYBarrageKit

开源软件介绍:

KYBarrageKit

This is a barrage of rendering library iOS high expansion, for most of the live broadcasting barrage scene.

中文介绍

reason

The company is doing direct business platform, products need to interface with the barrage in the live effect, there are some special animation effects, according to the needs of products, some open source projects combined with the Internet, he made the wheels, write a barrage of live rendering library, since meet the functional requirements of our products and.

features

  • 4 round support barrage rolling direction;
  • the rolling speed custom barrage;
  • the barrage of information for the NSMutableAttributedString type support, pictures and text barrage, Emoji emoticons etc.;
  • When is KYBarrageDisplayTypeImage type barrage, barrage support custom height;
  • the types can be extended (custom barrage currently supports plain text and graphics);
  • using CABasicAnimation to achieve animation effects to barrage;
  • supports batch sending barrage, barrage pause, restart, remove, start etc.;
  • support a barrage of memory warning, remove a barrage of buffer pool.

To achieve some of the basic functions, more follow-up to improve the function......

Effect as shown below:

feedback

  • if you need help, you can contact me or [weibo:] (http://weibo.com/balenn) by using QQ: 362108564.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

If there is anything you think is wrong, or have a better suggestion, the above contact can contact me. Thank you very much.

installation

requirements

  • Xcode 7 +
  • iOS 7.0 +

installation manual

First Download project ,the KYBarrageKit sub folder into the project, import the KYBarrageKit.h header file in use.

CocoaPods installation

You can add the following line of code to the KYBarrageKit to use the Podfile

	pod 'KYBarrageKit'

Use cocoaPods to manage the third party library, if the computer does not install cocoapods, please install the cocoapods. Installation method can refer to: [the latest cocoapods installation] (http://blog.sina.com.cn/s/blog_6ff6523d0102x8dq.html)

usage

  • in the need to use the function of local barrage rendering
 #import “KYBarrageKit”
  • create a KYBarrageManager *manager object, and the view add that you want to add a barrage of animation view, as shown below:
@interface ViewController ()@property (strong, nonatomic) KYBarrageManager *manager;@end@implementation ViewController- (void)viewDidLoad {  [super viewDidLoad];  // Do any additional setup after loading the view, typically from a nib.   self.view.backgroundColor = [UIColor whiteColor];    _manager = [KYBarrageManager manager];    _manager.bindingView = self.view;    _manager.scrollSpeed = 30;         _manager.refreshInterval = 1.0;  }
  • send a barrage
int a = arc4random() % 100000;    NSString *str = [NSString stringWithFormat:@"I'm coming %d ",a];        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str];    [attr addAttribute:NSForegroundColorAttributeName value:RandomColor() range:NSMakeRange(0, str.length)];        KYBarrageModel *m = [[KYBarrageModel alloc] initWithBarrageContent:attr];    [_manager showBarrageWithDataSource:m]; // Scroll Barrage 
  • set up a barrage of display area, support four direction, the default for the entire display area KYBarrageDisplayLocationTypeDefault

Global setting

_manager.displayLocation = KYBarrageDisplayLocationTypeTop;  

Or when the sub set barrage

   KYBarrageModel *m = [[KYBarrageModel alloc] initWithBarrageContent:attr];    m.displayLocation       = _manager. KYBarrageDisplayLocationTypeTop; 

Support for the display area of the corresponding NSInteger enumeration:

KYBarrageDisplayLocationTypevaluenote
KYBarrageDisplayLocationTypeDefault0the entire display area
KYBarrageDisplayLocationTypeTop1the top part
KYBarrageDisplayLocationTypeCenter2the middle part
KYBarrageDisplayLocationTypeBottom3the bottom part
KYBarrageDisplayLocationTypeHidden4Hidden
  • set the barrage position display support four direction.

Global setting

_manager.scrollDirection = KYBarrageScrollDirectRightToLeft;   

Or when the sub set barrage

   KYBarrageModel *m = [[KYBarrageModel alloc] initWithBarrageContent:attr];    m.direction       = _manager.scrollDirection; 

Support for the enumeration of NSInteger in four directions:

KYBarrageScrollDirectionvaluenote
KYBarrageScrollDirectRightToLeft0<<<<<
KYBarrageScrollDirectLeftToRight1>>>>>
KYBarrageScrollDirectBottomToTop2↑↑↑↑↑
KYBarrageScrollDirectTopToBottom3↓↓↓↓↓
  • active pull data set barrage barrage, commissioned by KYBarrageManagerDelegate, call the -delegate barrageManagerDataSource data

Set proxy,Open Access Initiative barrage

 _manager.delegate = self; [_manager startScroll]; //Open Access Initiative barrage

Calling method

- (id)barrageManagerDataSource {        int a = arc4random() % 10000;    NSString *str = [NSString stringWithFormat:@"%d digg",a];        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str];    [attr addAttribute:NSForegroundColorAttributeName value:RandomColor() range:NSMakeRange(0, str.length)];        KYBarrageModel *m = [[KYBarrageModel alloc] initWithBarrageContent:attr];    m.displayLocation = _manager.displayLocation;    m.direction       = _manager.scrollDirection;    m.barrageType = KYBarrageDisplayTypeImage;    m.object = [UIImage imageNamed:[NSString stringWithFormat:@"digg_%d",arc4random() % 10]];    return m;}
  • set the clear barrage.
[_manager closeBarrage];
  • set the barrage of pause and recovery.
    // 1. On the screen the barrage is suspended, and stop acquiring new barrage    // 2. The current barrage on the screen to start rolling, and to obtain a new barrage   [_manager pauseScroll];
  • type setting barrage currently supports plain text and graphics KYBarrageDisplayTypeDefault KYBarrageDisplayTypeImage, can customize other types of KYBarrageScene.
m.barrageType = KYBarrageDisplayTypeImage;

Other

The click event support barrage

If a barrage of type KYBarrageDisplayTypeImage barrage, please rewrite the ViewController touchesBegan method

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {    UITouch *touch = [touches anyObject];    CGPoint touchPoint = [touch locationInView:self.view];    [[_manager barrageScenes] enumerateObjectsUsingBlock:^(BarrageScene * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {        if ([obj.layer.presentationLayer hitTest:touchPoint]) {           /* if barrage's type is ` `KYBarrageDisplayTypeImage` `, add your code here*/            NSLog(@"message = %@",obj.model.message.string);        }    }];}

Such as click inside the DEMO barrage, barrage pause 3S after rolling, can also be extended to other events, as shown below:

encourage

If it accidentally gives you help, please do not mean to give it a star, it is the best support for it, thank you very much!

LICENSE

KYBarrageKit is licensed under the MIT protocol. Access to the LICENSE file for more information.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap