Circular Image in UITableViewCell

circular imageview ios swift 4
circular image in tableviewcell swift
uitableviewcell image circle swift
uitableviewcell imageview rounded corners swift
imageview circle ios
how to circle image in swift
uitableviewcell corner radius
make imageview circular objective c

I'm trying to create circular Images inside of my TableViewCell but something is going wrong. I guess that the cornerRadius is to big because there is not any Image displayed with this Code. If I set the cornerRadius on 30 for example, I can see the Images rounded but not in a clear circle .Why is this not working ?

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    var cell = tableView.dequeueReusableCell(withIdentifier: "QuestionLine")
    cell = UITableViewCell(style: .subtitle, reuseIdentifier: "QuestionLine")


    let user = users[indexPath.row]
     cell?.textLabel?.text = user.question
     cell?.detailTextLabel?.text = user.name

     let image = UIImage(named: user.profilePicture)
     cell?.imageView?.image = image
     cell?.imageView?.layer.cornerRadius = (image?.size.width)! / 2
     cell?.imageView?.clipsToBounds = true

    return cell!

}

Try this code

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    var cell = tableView.dequeueReusableCell(withIdentifier: "QuestionLine")
    cell = UITableViewCell(style: .subtitle, reuseIdentifier: "QuestionLine")


    let user = users[indexPath.row]
    cell?.textLabel?.text = user.question
    cell?.detailTextLabel?.text = user.name

    let image = UIImage(named: user.profilePicture)
    cell?.imageView?.image = image

    cell?.imageView?.layer.cornerRadius = (cell?.imageView?.frame.size.width)! / 2
    cell?.imageView?.layer.masksToBounds = true
    cell?.imageView?.layer.borderColor = colour.cgColor
    cell?.imageView?.layer.borderWidth = 1

    return cell!
}

Circular Image in UITableViewCell, Try this code override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView. How to Set Round Image in UITableView Round Images Some Times we need to make images round in UITableview (Here we have not taken any UITableviewcell) , Objective C provide default feature to add images as well as round the images.


The UITableViewCell's imageView will be sized to the height of the cell, If you want to customize the size of imageView try the below code.

   let image = UIImage(named: user.profilePicture)
    cell?.imageView?.image = image

    let itemSize = CGSize.init(width: 40, height: 40) // your custom size
    UIGraphicsBeginImageContextWithOptions(itemSize, false, UIScreen.main.scale);
    let imageRect = CGRect.init(origin: CGPoint.zero, size: itemSize)
    cell?.imageView?.image!.draw(in: imageRect)
    cell?.imageView?.image! = UIGraphicsGetImageFromCurrentImageContext()!;
    UIGraphicsEndImageContext()

    cell?.imageView?.layer.cornerRadius = (itemSize.width) / 2
    cell?.imageView?.clipsToBounds = true

Rounded images on iOS UITableView, UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:​UITableViewCellStyleSubtitle reuseIdentifier:nil]; … // Rounded corners. cell.​imageView. Applications 📘 Articles ️ Subscribe 🤔 About 2018/01/24 UICollectionView cells with circular images plus rotation support. Learn how to make rounded corners for UIImageView items wrapped inside collection view cells, with rotation support.


First make sure your image height and width is equal, then replace last 3 lines of code with these lines-

 cell?.imageView?.layer.cornerRadius = (image?.frame.size.width)!  /  2
 cell?.imageView?.masksToBounds = true

 return cell!

UICollectionView cells with circular images plus rotation support , Learn how to make rounded corners for UIImageView items wrapped inside collection view cells, with rotation support. All you have to do is assign values to the text Label, detail Text Label, and image View properties of your cell. The following illustration shows how the values you supply are positioned within the cell’s content area. If you do not supply an image for your cell, the cell distributes the extra space to the other content views.


Easy rounded corners on UITableViewCell image view, Here's a relatively easy way to achieve rounded corners on the standard image view in a UITableViewCell: cell.imageView.layer. Step 4: We need to add UITableViewCell class to the project. Choose New file -> Select cocoa touch classes group and then select UITableViewCell . Give the class name “MainView”. Create the .xib file select Resource -> Add -> New File ->User Interface-> select ViewXIB and give the XIB name “MainView.xib” .


How to Set Round Image in UITableView, Some Times we need to make images round in UITableview (Here we have not taken any UITableviewcell) , Objective C provide default  The first step, just like before, is to create another subclass of UITableViewCell. In the project navigator select the Views group and press Command-N to create a new file in this group. Create a new Cocoa Touch Class called FilmTableViewCell and make it a subclass of UITableViewCell.


Swift 5 Migration has Changed Circular Images |Apple Developer , The image view is a round profile picture with border. It has always worked. UITableViewCell does not have such methods. Please show all  This Swift code example will demonstrate how to create UITableView programmatically in Swift. The code example below will cover: Make ViewController conform to UITableViewDataSource, so that we can load table items into the table view Make ViewController conform to UITableViewDelegate, so that we can handle events like for example when user taps on a table…