开发者

iPhone SDK: How do I programmatically create squares?

Does anyone know how I can programmatically cre开发者_如何学编程ate a grid of squares. (each square being 10x10) ?

What i'd like to do is to simulate a digital display, so I would need to be able to set the colour of each individual square, after its been defined as well.

I know I could make each individual square in interface builder, but that would be simply impractical with all the required outlets.

Any help is greatly appreciated.


You'd need to create your own UIView class that implemented the necessary abstractions and carried out the relevant drawing within its drawRect method.

Have you looked at the Quartz 2D Programming Guide or Drawing and Printing Guide for iOS? These will provide the necessary background information on the various primative drawing operations and should at least point you in the correct direction.


You should have a look at the Apple sample project for example of drawing (square, circles, elipse, etc)

QuartzDemo

Hope this helps.


Create a custom view, override drawRect: and call UIRectFill to draw squares.

See this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜