Only bottom corners rounded

↘锁芯ラ 提交于 2019-12-11 11:13:18

问题


I have a textview below a tableView, both same Backgroundcolor so it appears as if its one View. Now I want the bottom corners of the textview to be rounded, but not the top ones (cause then you could see a gap between the textview and tableview). I found some answers on here, but somehow it just makes the bottom left corner rounded, not the right one? I also tried changing the order inside the Array, didn't work. Then I tried just the left corner, worked. But only the right corner didn't work?! Here is what I have at the moment

let rectShape = CAShapeLayer()
    rectShape.bounds = self.eventDescription.frame
    rectShape.position = self.eventDescription.center
    rectShape.path = UIBezierPath(roundedRect: self.eventDescription.bounds, byRoundingCorners: [.BottomLeft, .BottomRight], cornerRadii: CGSize(width: 20, height: 20)).CGPath




    self.eventDescription.layer.mask = rectShape

回答1:


Working code for me just check the constraints which you have added.

        let maskPath: UIBezierPath = UIBezierPath(roundedRect: self.button.bounds, byRoundingCorners: ([.BottomLeft, .BottomRight]), cornerRadii: CGSizeMake(10.0, 10.0))
        let maskLayer: CAShapeLayer = CAShapeLayer()
        maskLayer.frame = self.button.bounds
        maskLayer.path = maskPath.CGPath
        self.button.layer.mask = maskLayer



来源:https://stackoverflow.com/questions/36646115/only-bottom-corners-rounded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!