我有一個UIView名爲父。內部父嵌套命名Child1和CHILD2 2個UIViews(見圖像) Swift 3:嵌套UIView拐角不變圓
注意:有無邊距即0餘量的B/W兩者Child1,CHILD2和父。
我想要圍繞着父的角落。
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
仍然沒有運氣
請幫我
集.clipsToBounds =真。這將隱藏圖層 –
子項和父項兩者的溢出RadRadius和clipsToBounds = true – Rex
將父圖層的「masksToBounds」設置爲true。 –