只有底角是圆形的 [英] Only bottom corners rounded

查看:48
本文介绍了只有底角是圆形的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 tableView 下方有一个 textview,两者的背景颜色都相同,因此看起来好像是一个 View.现在我希望 textview 的底角是圆角,而不是顶部的角(因为那样你会看到 textview 和 tableview 之间的差距).我在这里找到了一些答案,但不知何故它只是使左下角变圆,而不是正确的?我也试过改变数组内的顺序,没有用.然后我尝试了左角,成功了.但只有右角不起作用?!这是我目前所拥有的

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

推荐答案

我的工作代码只需检查您添加的约束.

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

这篇关于只有底角是圆形的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆