How to set image in circle in swift

前端 未结 14 1757
星月不相逢
星月不相逢 2020-12-04 09:55

How can i make i circle picture with swift ?

My ViewController :

import UIKit
import Foundation

class FriendsViewController : UIViewController{

            


        
14条回答
  •  感情败类
    2020-12-04 09:58

    First you need to set equal width and height for getting Circular ImageView.Below I set width and height as 100,100.If you want to set equal width and height according to your required size,set here.

     var imageCircle = UIImageView(frame: CGRectMake(0, 0, 100, 100))
    

    Then you need to set height/2 for corner radius

     imageCircle.layer.cornerRadius = imageCircle.frame.size.height/2
     imageCircle.layer.borderWidth = 1
     imageCircle.layer.borderColor = UIColor.blueColor().CGColor
     imageCircle.clipsToBounds = true
     self.view.addSubview(imageCircle)
    

提交回复
热议问题