我想在视图控制器中绘制一个简单的行,而不使用“接口”构建器。
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.