如何在 Objective-C 中更改垃圾按钮的颜色?

How to Change trash button' color in Objective-C?

我有这段代码,它在导航栏上创建了一个蓝色的垃圾桶图标,我想将这个图标的颜色更改为黑色。我该怎么做? 这是我的代码:

//add trash button to navigation bar
    UIBarButtonItem *myTrash = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemTrash
                                                                             target: self
                                                                            action: @selector(deleteHandler)];

    NSArray* barButtons = [self.navigationItem.rightBarButtonItems arrayByAddingObject: myTrash];
    self.navigationItem.rightBarButtonItems = barButtons;

您可以尝试改变整体的色调window(这将帮助您实现一致的颜色主题):

self.window.tintColor = [UIColor blackColor];

或者导航栏的外观:

[UINavigationBar appearance].tintColor = [UIColor blackColor];