【发布时间】:2014-09-21 09:17:34
【问题描述】:
我重写了 MKAnnotationView 以在地图上显示自定义图像:
override init(annotation: MKAnnotation!, reuseIdentifier: String!) {
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
let img = UIImage(named: "annotation")
self.image = img
self.frame = CGRectMake(0, 0, 40, 40)
self.layer.cornerRadius = 20
self.contentMode = UIViewContentMode.ScaleAspectFit
self.centerOffset = CGPointMake(0, -20)
}
我想在地图上创建一个圆形图像,但cornerRadius 不起作用。
【问题讨论】:
-
试试
self.layer.masksToBounds = true。
标签: swift mapkit ios8 xcode6 mkannotationview