繁体   English   中英

Swift 3:嵌套的UIView(s)角落没有变圆

[英]Swift 3: nested UIView(s) corners not getting rounded

我有一个名为父亲UIView 内部父嵌套了两个名为Child1Child2的UIView 。(见图) 亲子关系

注意: 没有边距,即0个边距,包括Child1,Child2和Parent。

我试图围绕父母的角落

parentView.layer.cornerRadius = 10

并没有围绕孩子们的角落。(见图)

顶角不圆

顶角 不会在这里变 底角是圆角的,因为Child2是透明的,而Child1是彩色的。 父母是白色的。

到目前为止我尝试过的:

parentView.layer.cornerRadius = 10
child1.clipsToBounds = true

没运气

parentView.layer.cornerRadius = 10
let maskLayer = CAShapeLayer()
maskLayer.path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 10, height: 10)).cgPath
child1.layer.mask = maskLayer

仍然没有运气

请帮帮我

我认为你需要在clipToBound上添加parentView

parentView.clipsToBounds = true

如果你需要cornerRadius

import QuartzCore

parentView.layer.cornerRadius = yourvalue

如果你不想影子然后添加

parentView.layer.masksToBounds = true 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM