Pgm*_*eek 3 iphone core-graphics
我有4分说(x1,y1),(x2,y2),(x2,y3)和(x4,y4).我需要绘制一个带有这些点的矩形并在该矩形内填充一种颜色.谁能帮我这个?
Max*_*eod 24
首先,获取当前的图形上下文:
CGContextRef context = UIGraphicsGetCurrentContext();
Run Code Online (Sandbox Code Playgroud)
接下来,定义矩形:
CGRect myRect = {x1, y1, x2 - x1, y2 - y1};
Run Code Online (Sandbox Code Playgroud)
现在,设置填充颜色,例如红色
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
Run Code Online (Sandbox Code Playgroud)
设置笔触颜色,例如绿色:
CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0);
Run Code Online (Sandbox Code Playgroud)
最后,填充矩形:
CGContextFillRect(context, myRect);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8496 次 |
| 最近记录: |