tags:

views:

381

answers:

2

Hello all,

I am having a UIView and a UIViewContorller to that. I want to draw a rectangle in the view through my controller. So how to do that.

A: 

Two options, if you just need a static rectangle you could use an imasge and use UIImageView to display it where you need. If you need to draw it go to this faq https://developer.apple.com/iphone/library/codinghowtos/GraphicsAndAnimation/#2D-DRAW_LINES__CIRCLES__POLYGONS__AND_BEZIER_PATHS and then to the programming guide to drawing on the iphone, theres some helpful projects they provide to help you out as well.

Daniel
+1  A: 

You can add a subview to your view controller's view in viewDidLoad and set the background color to whatever color you want, provided that all you need is a solid color rectangle.

Kevlar
This is by far the easiest method.
Amagrammer