在您的情况下,最简单的方法(水平线)是添加一个背景 colored颜色 为黑色、框架为[0, 200, 320, 1]
的子视图.
代码示例(我希望没有错误-我没有使用Xcode编写):
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 1)];
lineView.backgroundColor = [UIColor blackColor];
[self.view addSubview:lineView];
[lineView release];
// You might also keep a reference to this view
// if you are about to change its coordinates.
// Just create a member and a property for this...
另一种方法是创建一个类,该类将在其drawRect方法中绘制一条线(您可以查看我的here代码示例).