Recently, I have been working on live broadcast, and I met some problems when I was working on bullet screen. A pretty good solution was found later, using dingo’s SDK, 😂. Nonsense will not say, we look at the effect ~







Overall project structure:







The following is a brief explanation of the implementation process:

Initialization: _wilddog = [[Wilddog alloc] initWithUrl:kWilddogUrl]; _snaps = [[NSMutableArray alloc] init]; _originFrame = self.view.frame; [self.wilddog observeEventType:WEventTypeChildAdded withBlock:^(WDataSnapshot *snapshot) { [self sendLabel:snapshot];  [self.snaps addObject:snapshot]; }];Copy the code
Send barrage:  - (UILabel *)sendLabel:(WDataSnapshot *)snapshot { float top = (arc4random()% (int)self.view.frame.size.height)-100; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width, top, 100, 30)]; label.textColor = [UIColor colorWithRed:arc4random()%255/255.f green:arc4random()%255/255.f blue:arc4random()%255/255.f alpha:1]; label.text = snapshot.value; [UIView animateWithDuration:7 animations:^{ label.frame = CGRectMake(-label.frame.size.width, top, 100, 30);  }completion:^(BOOL finished){ [label removeFromSuperview]; }]; [self.view addSubview:label]; return label; }Copy the code

Wild dog bullet screen download address: github.com/WildDogTeam…