iOS左滑默认和删除

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

    YFAdddressOfNationModel *model=_arrAddress[indexPath.row];

    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

        DLog(@"点击了删除");

        [self alert:@"确定要删除收货地址吗?" confirm:@"确定删除" cancel:@"取消" completion:^{

            //删除地址

            NSDictionary *para = @{@"application":@"DeleteExpressAddress.Req",

                                  

                                   @"id":model.idAddress

                                   

            };

              [self.request requestWithDictionary:para completion:^(BOOL success, id responseData) {

                  if (success) {

                      [self showHud:@"删除成功"];

                      [_arrAddress removeObjectAtIndex:indexPath.row];

     

                        [_mTableView reloadData];

                      

                  }

              }];

        }];

        

    }];

   

    

    

    UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"设为默认" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

        DLog(@"点击了设置默认");

     

        

        NSDictionary *para = @{@"application":@"UpdateExpressAddress.Req",

                               @"userid":[USER_DEFAULT objectForKey:kUserId],

                               @"username":model.username,

                               @"telephone":model.telephone,

                               @"delocation":model.delocation,

                               @"deaddress":model.deaddress,

                               @"design":@"1",

                               @"id":model.idAddress

                               

        };

          [self.request requestWithDictionary:para completion:^(BOOL success, id responseData) {

              if (success) {

//                  model.design=@"1";

//                  [_mTableView reloadData];

//                  YFShippingAddressListCell* cell = [tableView cellForRowAtIndexPath:indexPath];

//                  if (cell.leftBtnInstance.constant>=25) {

//                      isFirst=YES;

//                  }

//                  else{

//                      isFirst=NO;

//                  }

                  

                  _currentIndex=0;

                  _isFrom=@"default";

                  

                  [self getAddressList:@"默认"];

                  

              }

          }];

    }];

改背景颜色 直接设置

    editAction.backgroundColor = RGB(239, 239, 239);

    

//    editAction.backgroundColor=[UIColor lightGrayColor];

//    [editAction setValue:[UIColor whiteColor] forKey:@"titleTextColor"];

    改按钮颜色 需要这么设置(如果有多个的话)  ,单独改一个按钮标题颜色 [[UIButton appearance] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

            if (@available(iOS 11.0,*)) {

                for (UIView * lview in tableView.subviews) {

                    if ([lview isKindOfClass:NSClassFromString(@"UISwipeActionPullView")]){

//                        for (UIView * subcaceView in lview.subviews) {

                        //这里是单独的取到 第一个 来改颜色

                            if ([lview.subviews[0] isKindOfClass:NSClassFromString(@"UISwipeActionStandardButton")]) {

                                UIButton *btn=(UIButton *)lview.subviews[0];

                                [btn setTitleColor:Black1 forState:UIControlStateNormal];

                            }

//                        }

                    }

                    

                        

                }

            }

        });

    return @[deleteAction, editAction];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值