图中我的位置图标失真以下是代码
- (void)mapView:(MAMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
MAAnnotationView *view = views[0];
// 放到该方法中用以保证userlocation的annotationView已经添加到地图上了。
if ([view.annotation isKindOfClass:[MAUserLocation class]])
{
MAUserLocationRepresentation *pre = [[MAUserLocationRepresentation alloc] init];
pre.fillColor = [UIColor colorWithRed:0.196 green:0.196 blue:0.196 alpha:0.15];
pre.strokeColor = [UIColor colorWithRed:0.196 green:0.196 blue:0.196 alpha:0.8];
pre.image = [self reSizeImage:[UIImage imageNamed:@"gps_me"] toSize:CGSizeMake(21, 49)];
pre.lineWidth = 1;
// pre.lineDashPattern = @[@6, @3];
[_mapView updateUserLocationRepresentation:pre];
view.calloutOffset = CGPointMake(0, 0);
view.canShowCallout = NO;
self.userLocationAnnotationView = view;
}
}- (UIImage *)reSizeImage:(UIImage *)image toSize:(CGSize)reSize{
UIGraphicsBeginImageContext(CGSizeMake(reSize.width, reSize.height));
[image drawInRect:CGRectMake(0, 0, reSize.width, reSize.height)];
UIImage *reSizeImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return reSizeImage;
}
试过@2x不行,用更大分辨率的图片也不行
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货