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

后端 未结 6 1573
难免孤独
难免孤独 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:50

    if you want second type of output you should decrease the size of image.( eg 32x32 or 40x40) and instead of doing
    btnMyProfile.imageView?.layer.cornerRadius = (btnMyProfile.imageView?.frame.width)! / 2
    you should do

     btnMyProfile.imageView?.layer.cornerRadius = image.size.width / 2 
    

    the rest of your code seems OK..

提交回复
热议问题