【发布时间】:2016-08-09 04:43:05
【问题描述】:
我有这些尺寸,我想用这些尺寸画一个圆(宽度和高度显然相同)
205.0
218.0
245.0
257.0
310.0
510.0
当我在 205.5 处画圆时,它很好,它是一个完美的圆。但是当我从 218 开始时,圆圈会被切掉一点,每次我尝试做一个更大的圆圈时,它会越来越被切掉。我的问题是,无论大小如何,我如何创建一个完美的圆圈?
这是我的代码:
func drawCircle()
{
// Get the Graphics Context
let context = UIGraphicsGetCurrentContext();
// Set the circle outerline-width
CGContextSetLineWidth(context, 5.0);
// Set the circle outerline-colour
UIColor.redColor().set()
// Create Circle
CGContextAddArc(context, (round(frame.size.width))/2, round(frame.size.height)/2, (round(frame.size.width) - 10)/2, 0.0, CGFloat(M_PI * 2.0), 1)
// Draw
CGContextStrokePath(context);
}
frame.size.width 和 frame.size.height 是 205、218 等的数字。我会接受 Objective-C 的答案。
【问题讨论】:
-
“切断”是什么意思?不是一直在画圈吗?或者可能是它超出了它的容器视图的边缘或其他什么?
标签: ios objective-c swift