答案 0 :(得分:1)
我认为您需要将图像的渲染模式更改为始终原始。 它正在拍摄您图像的模板图像。
let img:UIImage = UIImage(named: "Bitcoin")!
img.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
尝试在将图像设置为条形按钮之前更改图像的渲染模式。 有关图像渲染模式的更多信息,请参阅this
目标C的....
UIImage *img = [UIImage imageNamed:@"Bitcoin"];
UIImage *original = [img imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
:)
答案 1 :(得分:0)
嗯,你必须先编辑你的图像。如果它不透明(PNG),并且图像中的对象必须是白色的,在你的情况下它现在是黑色的。然后在您的代码中更改色调颜色,如下所示:
let myImage = UIImage(named: "myImage")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
myImage.tintColor = UIColor.blackColor()
答案 2 :(得分:0)
答案 3 :(得分:0)
UIImage* image3 = [UIImage imageNamed:@"search_button.png"];
CGRect frameimg = CGRectMake(15,5, 25,25);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setImage:image3 forState:UIControlStateNormal];
[someButton addTarget:self action:@selector(Search_btn:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *searchButton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.leftBarButtonItem =mailbutton;