Basic realization and principle introduction of iOS projectile screen

Source: Internet
Author: User

Recently do the project need to achieve this function, although the sense of implementation is not very complicated, but I still do not want to write, because after all, the video app is very fire, and basically have the function of the bomb screen. But found on the internet did not have a lot to choose the third party, so recently wrote a demo, and put on GitHub (click to view)

Which implements my principle I am referring to this blog (click to view)

Achieve the effect:

Barrage Type: Supports scrolling from right to left, supporting middle top and bottom bounce.

Content: Support Emoticons, custom content text size and color

How to: Create a Cfdanmakuview object, configure it, and add it to the view
_danmakuView = [[CFDanmakuView alloc] initWithFrame:rect];_danmakuView.duration = 6.5;_danmakuView.centerDuration = 2.5;_danmakuView.lineHeight = 25;_danmakuView.maxShowLineCount = 15;_danmakuView.maxCenterLineCount = 5;_danmakuView.delegate = self;[self.view addSubview:_danmakuView];
Configure the data for the bullet screen
CFDanmaku* danmaku = [[CFDanmaku alloc] init];[danmakus addObject:danmaku];[_danmakuView prepareDanmakus:danmakus];// 对应视频的时间戳@property(nonatomic, assign) NSTimeInterval timePoint;// 弹幕内容@property(nonatomic, copy) NSAttributedString* contentStr;// 弹幕类型(如果不设置 默认情况下只是从右到左滚动)@property(nonatomic, assign) CFDanmakuPosition position;
Compliance with protocols and implementation of proxy methods
// 获取视频播放时间- (NSTimeInterval)danmakuViewGetPlayTime:(CFDanmakuView *)danmakuView{  if(_slider.value == 1.0) [_danmakuView stop]    ;  return _slider.value*120.0;}// 是否正在加载视频中- (BOOL)danmakuViewIsBuffering:(CFDanmakuView *)danmakuView{  return NO;}

For specific usage, please refer to demo (click to view)

If you find any bug or have any questions welcome message!

Basic realization and principle introduction of iOS projectile screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.