gpt4 book ai didi

iphone - MKPinAnnotationView:是否有超过三种颜色可用?

转载 作者:行者123 更新时间:2023-12-03 18:13:12 25 4
gpt4 key购买 nike

根据 Apple 文档,MKPinAnnotationView 的图钉颜色有红色、绿色和紫色。还有什么办法可以得到其他颜色吗?我在文档中没有找到任何内容。

最佳答案

更多;)

alt text enter image description here enter image description here

alt text enter image description here enter image description here

还有原来的:

alt text alt text enter image description here

alt text alt text enter image description here

alt text alt text enter image description here

代码:

- (MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView* anView =[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"test"];
anView.pinColor=MKPinAnnotationColorPurple;
UIImage* image = nil;
// 2.0 is for retina. Use 3.0 for iPhone6+, 1.0 for "classic" res.
UIGraphicsBeginImageContextWithOptions(anView.frame.size, NO, 2.0);
[anView.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData* imgData = UIImagePNGRepresentation(image);
NSString* targetPath = [NSString stringWithFormat:@"%@/%@", [self writablePath], @"thisismypin.png" ];
[imgData writeToFile:targetPath atomically:YES];
return anView;
}

-(NSString*) writablePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return documentsDirectory;
}

关于iphone - MKPinAnnotationView:是否有超过三种颜色可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1185611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com