使用UIBezierPath:byRoundingCorners:使用Swift 2和Swift 3 [英] Using UIBezierPath:byRoundingCorners: with Swift 2 and Swift 3

查看:1295
本文介绍了使用UIBezierPath:byRoundingCorners:使用Swift 2和Swift 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码使按钮的两个角变圆。

I'm using this code to make 2 corners of a button rounded.

let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: UIRectCorner.TopLeft | UIRectCorner.BottomLeft, cornerRadii: CGSizeMake(1.0, 1.0))

抛出错误:


二元运算符'|'不能应用于两个UIRectCorner操作数。

binary operator '|' cannot be applied to two UIRectCorner operands.

我如何使用Swift 2.0中的这个方法?

How do I use this method in Swift 2.0?

推荐答案

Swift 2:

let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: [UIRectCorner.TopLeft , UIRectCorner.BottomLeft], cornerRadii: CGSizeMake(1.0, 1.0))

Swift 3 Swift 4:

let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: [UIRectCorner.topLeft , UIRectCorner.bottomLeft], cornerRadii: CGSize(width:1.0, height:1.0))

这篇关于使用UIBezierPath:byRoundingCorners:使用Swift 2和Swift 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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