Latest 0.1.1
Homepage https://github.com/Feelinging/FEDanmuView
License MIT
Platforms ios 7.0, requires ARC
Authors

结构介绍

基于MVC思想

类: FEDanmuItem(Model) , FEDanmuItemView(View),FEDanmuSence(Controller)

FEDanmuItem
/**
 *  构造方法
 *
 *  @param text        文字内容
 *  @param actionType  弹幕的行为类型
 *  @param contentType 弹幕的内容类型
 *  @param attachView  弹幕会直接显示这个View
 */
+ (instancetype)itemWithText:(NSString *)text
                  actionType:(FEDanmuItemActionType)ationType
                 contentType:(FEDanmuItemContentType)contentType
                  attachView:(UIView *)attachView;

/**
 *  弹幕行为类型枚举
 */
typedef NS_ENUM(NSUInteger, FEDanmuItemActionType) {
    /**
     *  正常的弹幕,从边界进来再从另一个对称边界出去
     */
    FEDanmuItemActionTypeNormal = 0,
    /**
     *  悬浮弹幕,会在幕布上悬浮一段时间
     */
    FEDanmuItemActionTypeSuspend = 1, (还未实现该类型的特殊显示效果)
};

/**
 *  弹幕内容类型美剧
 */
typedef NS_ENUM(NSUInteger, FEDanmuItemContentType) {
    /**
     *  纯文本弹幕
     */
    FEDanmuItemContentTypeText = 0,
    /**
     *  使用UIView作为要显示内容的弹幕
     */
    FEDanmuItemContentTypeView = 1,
};

FEDanmuItemView: 作为MVC架构里的View层用于显示弹幕,实际使用中可能不需要接触这个类

/**
 *  构造方法
 *
 *  @param item 弹幕模型
 */
+ (instancetype)itemViewWithItem:(FEDanmuItem *)item;

FEDanmuSence: 作为MVC架构里面的Controller,用于控制弹幕的显示速度,发射频率,刷新帧率等

/**
 *  构造方法
 *
 *  @param items 弹幕模型数组
 */
+ (instancetype)senceWithItems:(NSArray<FEDanmuItem *> *)items;

如何构造一个弹幕幕布

// items
NSMutableArray *items = [NSMutableArray array];
NSArray *colors = @[[UIColor blueColor],[UIColor redColor],[UIColor purpleColor],[UIColor orangeColor]];
NSArray *texts = @[@"Hey Buddy",@"Are U ok Leibos!",@"Japanese Animation",@"Kirayamato",@"Happy New Year!"];
for (int i = 0; i < 10000; i++) {
    NSString *text = texts[arc4random_uniform((u_int32_t)texts.count)];
    FEDanmuItem *item = [FEDanmuItem itemWithText:text actionType:FEDanmuItemActionTypeNormal contentType:FEDanmuItemContentTypeText attachView:nil];
    item.font = [UIFont systemFontOfSize:arc4random_uniform(5) + 20.f];
    item.textColor = colors[arc4random_uniform((u_int32_t)colors.count )];
    [items addObject:item];
}
// FEDanmuSence
FEDanmuSence *sence = [FEDanmuSence senceWithItems:items];

控制弹幕的显示

To start display danmu use

- (void)start;

To pause display danmu use

- (void)pause;

To reset FEDanmuSence use

- (void)reset;

Also u can insert a danmu immediately

- (void)insertItem:(FEDanmuItem *)item;

image

License

Under MIT License

Latest podspec

{
    "name": "FEDanmuView",
    "version": "0.1.1",
    "summary": "u4e00u4e2au7b80u5355u597du7528u7684u7528u4e8eu663eu793au5f39u5e55u7684u89c6u56fe",
    "homepage": "https://github.com/Feelinging/FEDanmuView",
    "license": "MIT",
    "authors": {
        "Kira Yamato": "https://github.com/kirayamato1989"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/Feelinging/FEDanmuView.git",
        "tag": "0.1.1"
    },
    "requires_arc": true,
    "source_files": "FEDanmuView/*.{h,m}"
}

Pin It on Pinterest

Share This