快速阴影和拐角半径不可见

问题描述 投票:0回答:1

[when i put different color for bordercolor我想要一个具有一定阴影和拐角半径的视图,当我有阴影时,我遇到的问题是拐角半径不可用,我将masktobound设置为false并添加了此代码]

  func setShadow() {
    cardCBView.layer.cornerRadius = 10
    cardCBView.layer.borderWidth = 1.0
    cardCBView.layer.borderColor = #colorLiteral(red: 0.8980392157, green: 0.8980392157, blue: 0.8980392157, alpha: 0)
    cardCBView.layer.shadowColor = UIColor.black.cgColor
    cardCBView.layer.shadowOffset = CGSize.zero
    cardCBView.layer.shadowOpacity = 0.2
    cardCBView.layer.shadowRadius = 4.0
 }

我的结果类似于image:with masktobound off

with masktobound = on

我如何获得阴影和半径角?

感谢您的任何帮助

swift xcode view shadow radius
1个回答
0
投票
您应该设置

clipsToBounds = true

© www.soinside.com 2019 - 2024. All rights reserved.