【发布时间】:2016-03-29 08:11:07
【问题描述】:
我正在创建 Apple Watch。所以我附带了一个 Iphone 应用程序,在该应用程序中我使用 UIBezierPath 绘制了一个饼图。我需要将该图转换为 UIImage。这是我尝试过的代码:
GraphView.m
rectImage = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 260)];
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
UIGraphicsBeginImageContext(rectImage.frame.size);
CGFloat arcRadious = OUTER_RADIOUS;
CGFloat tmpStartAngle = startAngle;
CGFloat tmpEndAngle = endAngle;
UIBezierPath *path = [[UIBezierPath alloc] init];
path.lineWidth = 23;
[path addArcWithCenter:centre radius:arcRadious startAngle:tmpStartAngle endAngle:tmpEndAngle clockwise:YES];
[(UIColor*)_fillColours[index] setStroke];
[path stroke];
CGContextAddPath(context, path.CGPath);
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsPopContext();
UIGraphicsEndImageContext();
但在 Apple Watch 中,仅显示了图表的一部分。谁能告诉我我做错了什么。非常感谢任何帮助。
【问题讨论】:
标签: ios objective-c uiimage watchkit uibezierpath