美文网首页
OC-仿探探的卡片切换

OC-仿探探的卡片切换

作者: SK丿希望 | 来源:发表于2019-11-07 17:18 被阅读0次

主要是采用类似UITableViewdelegatedataSource思维来构造,同时参考别人Dome并进行改进完善

使用方法
// 懒加载 并设置代理数据源
- (HWDragCardView *)contentView {
    if (!_contentView) {
        CGFloat w = WidthScale(326);
        CGFloat h = HeightScale(439);
        CGFloat x = (CCWidth-w)/2;
        _contentView = [[HWDragCardView alloc] initWithFrame:CGRectMake(x, 80, w, h) style:HWDragStyleUpOverlay];
        _contentView.delegate = self;
        _contentView.dataSource = self;
        _contentView.remindNumber = 1; // 设置剩余提示数量
    }
    return _contentView;
}
数据源方法

注意:自定义cell必须继承HWDragCardCell

- (NSInteger)numberOfIndragCardView:(HWDragCardView *)dragCardView {
    return self.dataSources.count;
}

- (HWDragCardCell *)dragCardView:(HWDragCardView *)dragCardView cellForRowAtIndex:(NSInteger)index {
    FateCell *cell = [FateCell hw_loadViewFromNib];
    NSString *imageName = self.dataSources[index];
    cell.type = FateCellTypeDefault;
    cell.imageName = imageName;
    cell.seeClickBlcok = ^{
        NSLog(@"点击了查看详情");
    };
    return cell;
}
代理方法
// 拖拽中
- (void)dragCardView:(HWDragCardView *)dragCardView dragDropDirection:(HWDragDropDirection)dragDropDirection widthRatio:(CGFloat)widthRatio heightRatio:(CGFloat)heightRatio currentCell:(id)currentCell {
    FateCell *cell = (FateCell *)currentCell;
    CGFloat scale = 1 + ((kBoundaryRatio > fabs(widthRatio) ? fabs(widthRatio) : kBoundaryRatio)) / 4;
    FateCellType type = FateCellTypeDefault;
    switch (dragDropDirection) {
        case HWDragDropDirectionLeft:{
            self.leftButton.transform = CGAffineTransformMakeScale(scale, scale);
//            NSLog(@"<<<<<======滑");
            type = FateCellTypeDislike;
        }break;
        case HWDragDropDirectionRight:{
            self.rightButton.transform = CGAffineTransformMakeScale(scale, scale);
//            NSLog(@"======>>>>滑");
            type = FateCellTypeLike;
        }break;
        default:{
            type = FateCellTypeDefault;
            self.leftButton.transform = CGAffineTransformMakeScale(1, 1);
            self.rightButton.transform = CGAffineTransformMakeScale(1, 1);
        }break;
    }
    cell.type = type;
}
// 拖拽结束
- (void)dragCardView:(HWDragCardView *)dragCardView dragDropDirection:(HWDragDropDirection)dragDropDirection  dragEndWithIndex:(NSInteger)index {
    switch (dragDropDirection) {
        case HWDragDropDirectionLeft:{
            NSLog(@"选择了不喜欢");
        }break;
        case HWDragDropDirectionRight:{
            NSLog(@"选择了喜欢");
        }break;
        default:{
            NSLog(@"啥都没干");
        }break;
    }
}
// 剩余数量提醒
- (void)residualQuantityReminder:(NSInteger)remindNumber {
    if (remindNumber == 1)  {
        NSLog(@"请求数据了");
    } else if (remindNumber == 0) {
        NSLog(@"切换下一组了");
        [self loadData];
    }
}

Dome

相关文章

  • OC-仿探探的卡片切换

    主要是采用类似UITableView的delegate与dataSource思维来构造,同时参考别人Dome并进行...

  • 高仿探探卡片滑动效果

    高仿探探卡片滑动效果

  • 仿探探滑动卡片

    效果图 原谅我把妹子们换成了小机器人…. 实现思路 利用自定义RecyclerView LayoutManager...

  • 仿探探可滑动卡片

    这里是Demo地址:JYCardView,如果对您有帮助的话请点个star~

  • 仿探探卡片动画效果

    之前的公司有个效果类似探探的那种左滑不喜欢,右滑喜欢。当初没做成直接离职了。现在的公司有时间。所以考虑把这个完成。...

  • 仿探探样式循环卡片

    最近项目需求,自己封装了一个仿探探效果的小插件,由于时间原因,这里没有封装成一个类。现在先说一下思想,运用四个视图...

  • 仿探探卡片滑动选择

    探探的滑动选择妹子的功能,算是一个很经典的交互方式。自从出来以后可以说是备受关注,渐渐地很多类似功能的app也都有...

  • 仿<探探> 卡片滑动

    效果图 主要思路 容器View类:cardViewitem卡片类:cardItemView cardView 创建...

  • 开发笑话和游戏等一系列app的知识点总结2

    16:标准的伸缩式toolbar布局 17:仿探探滑动效果,修改将喜欢和不喜欢按钮放入卡片内即可。 https:/...

  • iOS 探探首页的卡片切换效果

    效果图: 最近公司要求写一个类似于探探的项目,在网上找了半天也没有找到合适的dome,所以就自己写了一个dome,...

网友评论

      本文标题:OC-仿探探的卡片切换

      本文链接:https://www.haomeiwen.com/subject/povvbctx.html