如何在Core Graphics / Quartz 2D中绘制圆角矩形? [英] How to draw a rounded rectangle in Core Graphics / Quartz 2D?

查看:452
本文介绍了如何在Core Graphics / Quartz 2D中绘制圆角矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为圆角矩形绘制轮廓。我知道我可以制作直线和圆弧,但也许还有一个圆形反射函数?

I need to draw an outline for a rounded rectangle. I know I can make lines and arcs, but maybe there is also a function for rounded rects?

推荐答案

而不是制作自己的路径和弧线之外的路径,你可以使用

Instead of making your own path out of lines and arcs, you can use

[UIBezierPath bezierPathWithRoundedRect:cornerRadius:]

[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]

(第二个允许你指定哪些角被舍入)

(the second one lets you specify which corners are rounded)

适用于iOS 3.2或更高版本。

Available in iOS 3.2 or later.

这篇关于如何在Core Graphics / Quartz 2D中绘制圆角矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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