Rounding UIImage and adding a border

前端 未结 9 1055
青春惊慌失措
青春惊慌失措 2020-12-09 18:19

so I want to show some pictures as annotations on the map. In order to do that I need to add the image property of the MKAnnotationView. I\'m using the regular images but I

相关标签:
9条回答
  • 2020-12-09 18:35

    simple one line code its works for me

    self.profileImage.layer.cornerRadius = self.profileImage.frame.size.width / 2
    
    0 讨论(0)
  • 2020-12-09 18:36

    Just fixed it. Apparently everything was working perfectly but I wasn't seeing the border. The original image is about 300x300 pixels and with 1.5 pixel border I was cropping it to fit 40x40 frame so the border was barely noticeable. Changing border width to a bigger number made it visible.

    0 讨论(0)
  • 2020-12-09 18:46
    imageView.layer.masksToBounds = true
    imageView.layer.borderWidth = 1.5
    imageView.layer.borderColor = UIColor.white.cgColor
    imageView.layer.cornerRadius = imageView.bounds.width / 2
    

    Try this.

    0 讨论(0)
提交回复
热议问题