无法在swift上查看该行

时间:2015-09-12 15:40:22

标签: swift xcode6 cgrectmake

我正在尝试添加从屏幕左侧开始向右的水平线。但这条线是不可见的。

let horizontalLine : CGRect = CGRectMake(45, height-50, 45, 55)
var testView : UIView = UIView(frame: horizontalLine)
self.view.addSubview(testView)

1 个答案:

答案 0 :(得分:0)

试试这个

let horizontalLine : CGRect = CGRectMake(45, 100-50, 45, 55)
//check value of height. this height>=(status bar height(20)+navigation bar height (44))
    var testView : UIView = UIView(frame: horizontalLine)
    testView.backgroundColor = UIColor.redColor()
    self.view.addSubview(testView)