在iphone sdk上绘制像Matrix Structure一样的点 [英] Draw Dots like Matrix Structure on iphone sdk

查看:109
本文介绍了在iphone sdk上绘制像Matrix Structure一样的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像iphone sdk中的矩阵结构一样绘制点。

I want to Draw dots like a Matrix Structure in iphone sdk.

如果我想生成点列和行(如2x2,3x3,4x4)。

if i want generate dots columns and rows (like 2x2,3x3,4x4).

但我不知道这一代。

我想要输出如下图像。

示例代码或教程的任何帮助..!

any help for example code or tutorial..!

推荐答案

您使用此代码......

You use this code ...

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

CGContextSetRGBFillColor(contextRef, 0, 0, 255, 0.1);
//CGContextSetRGBFillColor(contextRef, 0, 10, 200, 0.2);

CGContextSetRGBStrokeColor(contextRef, 0, 0, 255, 0.5);

// Draw a circle (filled)
//CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));

// Draw a circle (border only)
CGContextStrokeEllipseInRect(contextRef, CGRectMake(100, 100, 25, 25));



// Get the graphics context and clear it
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);



// Draw a green solid circle
CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(20, 50, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(50, 50, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(80, 50, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(110, 50, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(140, 50, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(170, 50, 8, 8));



CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(20, 100, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(50, 100, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(80, 100, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(110, 100, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(140, 100, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(170, 100, 8, 8));


CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(20, 150, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(50, 150, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(80, 150, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(110, 150, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(140, 150, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(170, 150, 8, 8));


CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(20, 200, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(50, 200, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(80, 200, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(110, 200, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(140, 200, 8, 8));

CGContextSetRGBFillColor(ctx, 0, 255, 0, 1);
CGContextFillEllipseInRect(ctx, CGRectMake(170, 200, 8, 8));
}

您的输出显示为

Your Output shows like

这篇关于在iphone sdk上绘制像Matrix Structure一样的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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