Image not showing in imageView if I used circular image

后端 未结 2 426
再見小時候
再見小時候 2021-01-27 00:33

I have a table view and I need to show author_img in section header. In ViewForSectionHeader method, I want to make the image to be circular. But If I did that, the images are n

2条回答
  •  迷失自我
    2021-01-27 01:25

    It may come from the fact that you are setting the cornerRadius too early, the final size of your author_img is not fixed yet. Try to set that cornerRadius when you are sure that the layout of your cell has been entirely calculated.

    For test purpose, just to make sure it is coming from this behaviour, try to hardcode the cornerRadius.

    cell.author_img.layer.cornerRadius = 10
    

    If your image has a slight cornerRadius, it means that the issue is coming from what I explained earlier, if it is still not showing, it is coming from something else.

    If it does come from the fact the size of your image is not fixed, try to set your cornerRadius in something like viewDidAppear, I mean the latest you can do.

提交回复
热议问题