我overrided MKAnnotationView到在地圖上顯示自定義圖像: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不工作。
有人cal幫助我嗎?
謝謝。
嘗試'self.layer.masksToBounds = TRUE'。 – Anna 2014-09-23 02:34:15
不起作用:( – Kobazzo 2014-09-23 18:59:00