Swift:No '|' candidates produce
2017-09-25 本文已影响0人
valiant_xin
之前一直使用OC开发,不过很多公司如今已经都开始用Swift了,没办法,只能自己慢慢琢磨Swift了。今天写了一个简单的demo,创建一个新的控件显示出来。突发奇想,想要对它进行切圆角,当然是切其中的两个圆角了。
在切圆角的时候,我选择适用CAShapeLayer和UIBezierPath进行圆角设置。当然也是因为使用这种方式的性能比较好了,对内存的开销比较少,渲染速度也挺快。
不过,在使用的过程中,因为沿用OC的习惯,在使用分隔符‘|’的时候一直报错。

这里只能传进来一个参数,想要像OC那样使用‘|’很显然不太可能。所以使用了如下的方法:

将两个要切圆角的提取出来放到一起,这样就能直接将最后的值赋到方法中,也不会报错。运行的结果如下:

demo就不发了,简单几句代码就能搞定,代码截图:
