我已将 UIButtonTypeDetailDisclosure
的图像更改为下图,但问题是图像变成了蓝色。我的问题在哪里?
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
*infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton setImage:[UIImage imageNamed:@"carcar.png"] forState: UIControlStateNormal];
pinView.rightCalloutAccessoryView = infoButton;
}
最后更新:用最后一个 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/