简体   繁体   中英

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

我想在视图控制器中绘制一个简单的行,而不使用“接口”构建器。

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM