如何在导航栏后退按钮上设置彩色可自定义图像?

时间:2017-02-06 10:06:46

标签: ios objective-c xcode uinavigationbar

我完成了以下用于自定义导航栏后退按钮的代码。但我面临着设置原始图像的问题。无论条形色彩的颜色如何,同样的颜色也应用于该图像。但我想在Objective-C的导航栏上找到原始图像。

dft %>%
  group_by(id) %>%
  mutate(diff_days = difftime(date, lag(date))) %>%
  filter(group == "A") %>%
  select(diff_days)

2 个答案:

答案 0 :(得分:1)

使用imageWithRenderingMode获取原始图片。

UIImage *image = [[UIImage imageNamed:@"logoHeader"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleDone target:self action:nil];

self.navigationItem.leftBarButtonItem = backButton;

答案 1 :(得分:-1)

这也适用于我的情况,

            <telerik:RadAutoCompleteBox.DropDownItemTemplate>
                <DataTemplate>
                    <Border BorderThickness="0" Background="White" Margin="-2, -2.2">
                        <TextBlock Text="{Binding Path=Subject}" Padding="3"/>
                    </Border>
                </DataTemplate>
            </telerik:RadAutoCompleteBox.DropDownItemTemplate>

请参阅UIImage* image1 = [UIImage imageNamed:@"logoHeader"]; CGRect frame1img = CGRectMake(0, 0, image1.size.width, image1.size.height);//Or you can set by frame CGRectMake(0, 0, 25, 25); UIButton *closeBtn = [[UIButton alloc] initWithFrame:frame1img]; [closeBtn setBackgroundImage:image1 forState:UIControlStateNormal]; [closeBtn addTarget:self action:@selector(actionToCloseBtn:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *leftBarbutton =[[UIBarButtonItem alloc] initWithCustomView:closeBtn]; self.navigationItem.leftBarButtonItem=leftBarbutton; 方法集自定义视图initWithCustomView