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 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺