ios - UIButtonTypeDetailDisclosure 颜色变化

标签 ios uibutton ios7 uiimage mkannotationview

我已将 UIButtonTypeDetailDisclosure 的图像更改为下图,但问题是图像变成了蓝色。我的问题在哪里?

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
*infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

[infoButton setImage:[UIImage imageNamed:@"carcar.png"] forState: UIControlStateNormal];

pinView.rightCalloutAccessoryView = infoButton;
} 

enter image description here

enter image description here

最后更新:用最后一个 infoButton.frame 解决。

    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeCustom];

    UIImage *carImage = [UIImage imageNamed:@"carcar.png"];

    if ([carImage respondsToSelector:@selector(imageWithRenderingMode:)])
    {
        carImage = [carImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }

    [infoButton setImage:carImage forState: UIControlStateNormal];

    infoButton.frame = CGRectMake(0, 0, 32, 32);

    pinView.rightCalloutAccessoryView = infoButton;

最佳答案

我遇到了类似的问题并按如下方式解决(使用您的代码):

UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton setTintColor:[UIColor clearColor]];

UIImage *carImage = [[UIImage imageNamed:@"carcar.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

[infoButton setBackgroundImage:carImage forState:UIControlStateNormal];

关于ios - UIButtonTypeDetailDisclosure 颜色变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19957331/

相关文章:

ios - 保存或返回到以前的 iOS 场景

iphone - 我们如何在 UIButton 上添加 UIPopOverController?

ios - 带有按钮点击检测的 NSInvalidArgumentException

ios - 地址簿允许后代码执行延迟

ios - 如何在我的类(class)中使用协议(protocol)和委托(delegate)?

ios - 删除 UITableView 行 - 复制单元格

ios - 密码保护 iPhone 应用程序

swift - 以编程方式将按钮放在一起

css - 带有 iOS7 的 iPhone 在横向模式下不显示文档的全高

ios - 如何在 iOS 7 下更改 UIPickerView 中文本的颜色?