2017-07-29 89 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