xinyoulingxi1_tong 2013-01-05 01:43 采纳率: 0%
浏览 4451

iphone中drawRect画图形

我的代码如下:

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGFloat commentHeight = 0;


        CGSize commentSize = [self.highlightItem_.comment sizeWithFont:[UIFont fontWithName:kProximaNova size:18] constrainedToSize:CGSizeMake(rect.size.width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
        commentHeight = commentSize.height + 50;

        CGContextSetRGBStrokeColor(context, 68/255.f, 68/255.f, 68/255.f, 1.0);
        CGContextSetRGBFillColor(context, 68/255.f, 68/255.f, 68/255.f, 1.0);
        CGContextSetLineJoin(context, kCGLineCapSquare);
        CGContextSetLineWidth(context, 1.0);

        CGMutablePathRef pathRef = CGPathCreateMutable();

        CGPathMoveToPoint(pathRef, NULL, 0, rect.size.height - commentHeight);
        CGPathAddLineToPoint(pathRef, NULL, 20, rect.size.height - commentHeight);
        CGPathAddLineToPoint(pathRef, NULL, 25, rect.size.height - commentHeight - 10);
        CGPathAddLineToPoint(pathRef, NULL, 30, rect.size.height - commentHeight);
        CGPathAddLineToPoint(pathRef, NULL, rect.size.width, rect.size.height - commentHeight);
        CGPathAddLineToPoint(pathRef, NULL, rect.size.width, rect.size.height);
        CGPathAddLineToPoint(pathRef, NULL, 0, rect.size.height);
        CGPathCloseSubpath(pathRef);

        CGContextAddPath(context, pathRef);
        //CGContextFillPath(context);
        CGContextDrawPath(context, kCGPathFill);


        CGPathRelease(pathRef);
}

但是没有画出预期的图片,不知道为什么?请高手指教,谢谢

  • 写回答

1条回答

  • shiter 人工智能领域优质创作者 2015-01-13 14:18
    关注

    可以学习一下,这个重绘的机制:
    http://blog.csdn.net/fww330666557/article/details/8647608

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?