试图使用CGContextAddArc ...没有绘制? [英] Trying to use CGContextAddArc... nothing is drawn?

查看:86
本文介绍了试图使用CGContextAddArc ...没有绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个弧。

- (void)viewDidLoad {
    [super viewDidLoad];
    CGRect rect = CGRectMake(0,0,340,480);  
    UIView *ui = [[UIView alloc] initWithFrame:rect];
    [self.view addSubview:ui];
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextAddArc(context, 50, 50, 20, 0, 30, 0); 
}


推荐答案

电弧在其可见之前。你在屏幕上有一个路径,但你必须笔画或填充之前绘制明显。

You have to stroke or fill the arc before its visible. You've got a path on screen but you have to stroke or fill it before draws visibly. Use these to do that..

//set the fill or stroke color
CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1.0);
CGContextSetRGBStrokeColor(context, 0.5, 0.5, 0.5, 1.0);

//fill or draw the path
CGContextDrawPath(context, kCGPathStroke);
CGContextDrawPath(context, kCGPathFill);

这篇关于试图使用CGContextAddArc ...没有绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆