Can't set cornerRadius AND shadow on layer that has an image view stretched to its bounds?

前端 未结 5 747
醉话见心
醉话见心 2020-12-31 03:00

This is stumping me. I have a UIView (call it \"parent\"). The bottommost subview of that view is a UIImageView (call it \"child\"), whose frame occupies the entirety of the

5条回答
  •  滥情空心
    2020-12-31 03:37

    If you want shadow layer with corner radius for imageview is that better solution put imageview a view as subview with 1 point margin.. and

     imgBrandLogo.backgroundColor = UIColor.blue
        imgBrandLogo.layer.cornerRadius = imgBrandLogo.frame.height/2
        imgBrandLogo.clipsToBounds = true
        viewBrandLogo.layer.shadowColor = UIColor(rgb:0x262626,alpha:0.24).cgColor
        viewBrandLogo.layer.shadowOffset = CGSize(width: 0, height: 1)
        viewBrandLogo.layer.shadowOpacity = 1
        viewBrandLogo.layer.shadowPath = UIBezierPath(roundedRect:imgBrandLogo.bounds , cornerRadius: imgBrandLogo.frame.height/2).cgPath
        viewBrandLogo.backgroundColor = UIColor.clear.withAlphaComponent(0.0)
    

提交回复
热议问题