I want to draw a simple line in view controller with out using Interface builder.
Asked
Active
Viewed 4,895 times
1
-
possible duplicate of [How do I draw a line on the iPhone?](http://stackoverflow.com/questions/856354/how-do-i-draw-a-line-on-the-iphone) – Sherm Pendley Mar 29 '11 at 13:18
2 Answers
3
If you only want to draw horizontal or vertical line, you can just use UIView.
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(<startingX>, <startingY>, <width>, <height>)];
lineView.backgroundColor = <desiredColor>;
//assume self is UIViewController or its sublcass
[self.view addSubview:lineView];
[lineView release];

manicaesar
- 5,024
- 3
- 26
- 29
1
Try this question. I know this references InterfaceBuilder, but you can dynamically add your custom view using Obj-C like mentioned here.

Community
- 1
- 1

FreeAsInBeer
- 12,937
- 5
- 50
- 82
-
True, but duplicates should be closed as such, not answered with a link. Once it's closed, a link to the original will appear in the comments anyway, and that helps keep all the answers together in one place. Thanks! – Sherm Pendley Mar 29 '11 at 13:20
-
-
No worries - it *is* a good answer, and your rep isn't high enough to vote for closing anyway. I gave you a +1 to help with that second problem, at least. :-) – Sherm Pendley Mar 29 '11 at 13:33