How to draw a simple line without using Interface Builder in iphone sdk?
I开发者_开发百科 want to draw a simple line in view controller with out using Interface builder.
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];
Try this question. I know this references InterfaceBuilder, but you can dynamically add your custom view using Obj-C like mentioned here.
精彩评论