所以,我有这样的代码,它画一个圆圈,在它周围画一条线。
- (void)drawRect:(CGRect)rect
{
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(contextRef, 40.0);
CGContextSetRGBFillColor(contextRef, 0.0, 0.0, 0.0, 1.0);
CGContextSetRGBStrokeColor(contextRef, 132.0/255.0, 128.0/255.0, 128.0/255.0, 1.0);
CGContextFillEllipseInRect(contextRef, rect);
CGContextStrokeEllipseInRect(contextRef, rect);
}问题是,这条线的一半宽落在正方形之外。所以,我想做的是,创建一个相对于线宽的嵌入,来弥补这一点。或者,也许有一种方法,告诉我的线保持在圆的边界内?
发布于 2013-12-10 21:17:19
在灌装之前,
rect = CGRectInset(rect, 1, 1);https://stackoverflow.com/questions/20505361
复制相似问题