在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:KYBarrageKit开源软件地址:https://gitee.com/kingly09/KYBarrageKit开源软件介绍:KYBarrageKitThis is a barrage of rendering library iOS high expansion, for most of the live broadcasting barrage scene. reasonThe 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
To achieve some of the basic functions, more follow-up to improve the function...... Effect as shown below: feedback
If there is anything you think is wrong, or have a better suggestion, the above contact can contact me. Thank you very much. installationrequirements
installation manualFirst Download project ,the KYBarrageKit sub folder into the project, import the CocoaPods installationYou can add the following line of code to the KYBarrageKit to use the Podfile pod 'KYBarrageKit' Use usage
#import “KYBarrageKit”
@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; }
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
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
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
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;}
[_manager closeBarrage];
// 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];
m.barrageType = KYBarrageDisplayTypeImage; OtherThe click event support barrage If a barrage of type - (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: encourageIf 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! LICENSEKYBarrageKit is licensed under the MIT protocol. Access to the LICENSE file for more information. |
请发表评论