我想將圖像設置爲MKAnnotationView。
但圖像沒有反映出來。這是正常的紅色針腳。
MKAnnotationView.image不反映
ViewController.m
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "CustomAnnotation.h"
@interface ViewController()<MKMapViewDelegate>
@end
@implementation ViewController{
MKMapView* _mapView;
}
- (void)viewDidLoad{
CustomAnnotation* annotation = [[CustomAnnotation alloc]init];
annotation.coordinate = CLLocationCoordinate2DMake(35.6699877, 139.7000456);
annotation.image = [UIImage imageNamed:@"annotation.png"];
[_mapView addAnnotations:@[annotation]];
}
CustomAnnotation.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface CustomAnnotation : MKAnnotationView
@property (readwrite, nonatomic) CLLocationCoordinate2D coordinate;
@property (readwrite, nonatomic, strong) NSString* title;
@end
CustomAnnotation.m
#import "CustomAnnotation.h"
@implementation CustomAnnotation
@end