开发者

How to draw a simple line without using Interface Builder in iphone sdk?

开发者 https://www.devze.com 2023-02-20 08:03 出处:网络
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.

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.

0

精彩评论

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

关注公众号