【发布时间】:2015-06-19 13:21:24
【问题描述】:
我需要快速创建一个只有两个圆角的矩形(Objective C 代码也可以)。
目前我的代码正在使用
创建两个矩形CGPathCreateWithRoundedRect(CGRectMake(0, 0, 30, 60), 5, 5, nil);
和
CGPathCreateWithRoundedRect(CGRectMake(0, 0, 30, 60), 0, 0, nil);
并合并它们(有两个直角和两个圆角),但我对代码不满意,我很确定应该有更好的方法来做到这一点。
我是 iOS 和图形开发和 swift 的新手。
【问题讨论】:
-
developer.apple.com/library/ios/documentation/UIKit/Reference/…:
bezierPathWithRoundedRect:byRoundingCorners:cornerRadii: -
像往常一样,*Swift 中发生了许多小的变化,例如常量的大写等。建议向下滚动到最新答案。
-
在这里查看我的答案,它将涵盖所有内容:- https://stackoverflow.com/a/68342661/9863222
标签: ios swift core-graphics