2017-07-29 82 views
0

我有一个UIView名为。内部父嵌套命名Child1CHILD2 2个UIViews(见图像) Parent-Child RelationSwift 3:嵌套UIView拐角不变圆

注意:有无边距即0余量的B/W两者Child1,CHILD2和父。

我想要围绕着父的角落。

parentView.layer.cornerRadius = 10 

不圆了孩子们的角落。(见图片)

The top corners do not get rounded

顶部边角最终得到这里。底角被舍入,因为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 

仍然没有运气

请帮我

+0

集.clipsToBounds =真。这将隐藏图层 –

+0

子项和父项两者的溢出RadRadius和clipsToBounds = true – Rex

+1

将父图层的“masksToBounds”设置为true。 –

回答

3

我认为你需要添加clipToBoundparentView

parentView.clipsToBounds = true 
+0

像魅力一样工作! –

+0

谢谢...... – Vivek

0

如果您需要cornerRadius

import QuartzCore 

parentView.layer.cornerRadius = yourvalue 

,如果你不想阴影再加入

parentView.layer.masksToBounds = true