PresentView *presentView = [[PresentView alloc] init];
presentView.delegate = self;
presentView.frame = CGRectMake(0, 200, 200, 130);
[self.view addSubview:presentView];
- 返回自定义cell样式(required)
- (PresentViewCell *)presentView:(PresentView *)presentView cellOfRow:(NSInteger)row
{
return [[CustonCell alloc] initWithRow:row];
}
- 设置cell展示的数据(required)
- (void)presentView:(PresentView *)presentView configCell:(PresentViewCell *)cell sender:(NSString *)sender giftName:(NSString *)name
{
for (PresentModel *model in self.dataArray) {
if ([model.sender isEqualToString:sender] && [model.giftName isEqualToString:name]) {
CustonCell *customCell = (CustonCell *)cell;
customCell.model = model;
}
}
}
- 监听cell的点击事件(optional)
- (void)presentView:(PresentView *)presentView didSelectedCellOfRowAtIndex:(NSUInteger)index
{
CustonCell *cell = [presentView cellForRowAtIndex:index];
NSLog(@"你点击了:%@", cell.model.giftName);
}
presentView.showTime = 3.5;
presentView.cellHeight = 35;
[self.presentView insertPresentMessages:@[self.dataArray[2]] showShakeAnimation:YES];
效果图如下: 关于Demo的基本逻辑分析,详见:仿映客刷礼物效果---基本逻辑实现