2016-02-22 54 views
-1

我在一个基本的应用程序工作,出于某种原因,我不能以CGPointMake为中心视图(文本框)。我知道textBox.center = self.view.center;将中心视图,但我不知道为什么CGPointMake不工作。我正在使用Swift。CGPoint不正确定位UIView

textBox.font = UIFont.systemFontOfSize(15) 
    textBox.keyboardType = UIKeyboardType.Default 
    textBox.textAlignment = NSTextAlignment.Center 
    CGPointMake(187.5, 333.5) 
    textBox.returnKeyType = UIReturnKeyType.Done 
    self.view.addSubview(textBox) 
+2

'CGPointMake(187.5,333.5)'未分配给textBox的任何属性。你确定 ? –

回答

-1

你可以通过这个代码

CGPointMake(187.5, 333.5) 提出的观点,但你没有文本框的中心分配到了这一点。 因此,使用此代码

textBox.center = CGPointMake(187.5, 333.5);