GMS圆形图标

时间:2016-09-19 13:05:34

标签: ios gmsmapview

我正在使用谷歌地图实施地图,并且每个标记我都有图像。我的问题是:我怎样才能使图标圆? 我尝试使用经典的layer.cornerRadius,但它没有用。

viewDidLoad中

self.artistImageView = [[UIImageView alloc] init];
self.artistImageView.layer.cornerRadius = self.artistImageView.frame.size.width / 2.0f;
self.artistImageView.layer.borderWidth = 2.0f;
self.artistImageView.layer.borderColor = [UIColor blackColor].CGColor;
self.artistImageView.layer.masksToBounds = YES;

和populateMap方法:

FBMarker *marker = [FBMarker markerWithPosition:pin.coordinate];
marker.title = pin.title;
self.artistImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:artist.artistImage]]];
marker.icon = self.artistImageView.image;
marker.subtitle = pin.subtitle;
marker.phone = pin.phone;
marker.map = self.mapView

1 个答案:

答案 0 :(得分:0)

您可以轻松地将其用于任何图像操作: Toucan Swift

我的例子:

  marker.icon = Toucan(image: marker.icon!).maskWithEllipse(borderWidth: 2, borderColor: UIColor.whiteColor()).image

enter image description here