1
我一直在試圖實現一個像這張圖中的UIMapView圖標。有人知道這個應用程序如何創建縮略圖嗎?添加一個帶引腳的UIMapView縮略圖
編輯
嘗試用下面的代碼來實現這一點:
CLLocationCoordinate2D restaurantLocation = CLLocationCoordinate2DMake(Latitude, Longitude);
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(restaurantLocation, 1000, 1000);
_mapView.region = region;
_mapView.hidden = NO;
_annotation = [[MKPointAnnotation alloc] init];
_annotation.coordinate = restaurantLocation;
//annotation.title = _restaurantInformation
[_mapView addAnnotation:_annotation];
UIGraphicsBeginImageContext(_mapView.frame.size);
[_mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGSize newSize;
newSize.width = 50; // any width u want
newSize.height= 80; // any height u want
UIGraphicsBeginImageContext(newSize);
[mapImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
_mapThumbnail.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我說我使用的問題,實現的代碼特定位置的縮略圖和它的工作,但它仍然似乎並不奏效。我做對了嗎?謝謝 – Apollo
我已經成功地啓動並運行了MKMapView,但是捕獲當前繪圖並將其設置爲UIImage的方法無效。 – Apollo