且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Swift中创建带有边框和阴影的圆角图像作为MKAnnotationView?

更新时间:2021-12-18 23:46:13

在返回新的"anView"之前,您可以使用以下代码:

before returning your new "anView" you can use this code:

anView!.layer.cornerRadius = anView!.frame.size.height/2
anView!.layer.masksToBounds = true
anView!.layer.borderColor = UIColor.whiteColor()
anView!.layer.borderWidth = 5

这将使其带有白色边框.

That'll make it round with a white border.

如果您想在图像本身上加边框,则可以使用图像视图"并将其作为MKAnnotationView的子视图.

If instead you want a border on the image itself you could just use an Image View and put it as a subview of your MKAnnotationView.