通过将 modifyCell 替换为新的 sf 符号 chevron.right 来更改人字形颜色

Change chevron color by replacing it in modifyCell with new sf symbol chevron.right

我想使用系统图像 chevron.right 作为我的附件图标并替换当前存在的图像以便我可以控制颜色。现在 iOS 13+ 的色调不会像文本那样更新,以前的版本可以使用。我需要使用系统映像 sf symbol chevron.right.

objective c 而不是 swift 中完成此操作
- (void)modifyCell:(UITableViewCell*)tableCell andIndex:(NSIndexPath *)indexPath {

    Event *event = [self findDataInRow:[self findRow:indexPath]];

    if(event != nil)
    {
        EventsTableViewCell *eventTableCell = (EventsTableViewCell *)tableCell;

        if(eventTableCell != nil)
        {

        }
    }

当您 return 中的单元格位于:

时,您需要操纵出队 UITableViewCellaccessoryView 的颜色
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath

所以在一个简单的数据源实现中。

@implementation XViewController

- (UIColor *)colorForIndex:(NSInteger)index {
    NSArray *colors = @[UIColor.redColor,UIColor.greenColor,UIColor.blueColor];
    return colors[index % 3];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.tintColor = [UIColor orangeColor];
}


- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    cell.textLabel.text = @"hello world";
    cell.imageView.image = [UIImage systemImageNamed:@"pencil.slash"];
    UIImageView *accessory = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"pencil.and.outline"]];
    accessory.tintColor = [self colorForIndex:indexPath.row];
    cell.accessoryView = accessory;

    return cell;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}


@end

选择您喜欢的系统映像而不是 "pencil.and.outline",后者只是为了证明它不是标准的 V 形图案。观察 LHS 单元格图像采用 orange 的视图色调,而 RHS 上的辅助视图采用您想要的任何颜色。