How can I set UIButton image, which Image is round shape with border

后端 未结 6 1571
难免孤独
难免孤独 2021-01-24 04:04

How can I set UIButton image, which Image is round shape with border I write related code but image not displaying in proper round shape.. Here is my code..

             


        
6条回答
  •  失恋的感觉
    2021-01-24 04:42

        func roundedImageView(imgView: UIImageView, borderWidth: Float, borderColor: UIColor)
    {
        imgView.layer.cornerRadius = imgView.frame.size.width / 2
        imgView.clipsToBounds = true
        imgView.layer.borderWidth = CGFloat(borderWidth)
        imgView.layer.borderColor = borderColor.cgColor
    }
    

提交回复
热议问题