- (NSString *)tableView:(nonnull UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { return @""; }
- (NSArray<UITableViewRowAction *> *)tableView:(nonnull UITableView *)tableView editActionsForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { UITableViewRowAction *configureAction; configureAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"" handler:^(UITableViewRowAction * __nonnull action, NSIndexPath * __nonnull indexPath) { // handle }]; return @[ configureAction ]; }
UIImage *patternImage = [UIImage imageNamed:@"gear_compact"]; // 50x50 configureAction.backgroundColor = [UIColor colorWithPatternImage:patternImage];
UIImage *patternImage = [UIImage imageNamed:@"gear_fullsize"]; // 240x90 configureAction.backgroundColor = [UIColor colorWithPatternImage:patternImage];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [UITableViewCell new]; cell.textLabel.text = self.objects[indexPath.row]; cell.textLabel.numberOfLines = 0; UIView *actionView = [UIView new]; actionView.backgroundColor = [UIColor greenColor]; [cell addSubview:actionView]; [actionView autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:cell]; [actionView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:cell]; [actionView autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:cell]; [actionView autoAlignAxis:ALAxisHorizontal toSameAxisOfView:cell.contentView]; UIImageView *actionIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gear_compact"]]; [actionView addSubview:actionIcon]; [actionIcon autoAlignAxis:ALAxisHorizontal toSameAxisOfView:actionView]; [actionIcon autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:actionView withOffset:10]; UILabel *actionLabel = [UILabel new]; actionLabel.text = @""; [actionView addSubview:actionLabel]; [actionLabel autoAlignAxis:ALAxisHorizontal toSameAxisOfView:actionView]; [actionLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:actionIcon withOffset:5]; return cell; }
- (NSArray<UITableViewRowAction *> *)tableView:(nonnull UITableView *)tableView editActionsForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { UITableViewRowAction *configureAction; configureAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"(i) " handler:^(UITableViewRowAction * __nonnull action, NSIndexPath * __nonnull indexPath) { // handle }]; return @[ configureAction ]; }
Source: https://habr.com/ru/post/261905/
All Articles