Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios CGPoint无法正确定位UIView_Ios_Swift - Fatal编程技术网

Ios CGPoint无法正确定位UIView

Ios CGPoint无法正确定位UIView,ios,swift,Ios,Swift,我正在开发一个基本的应用程序,由于某些原因,我无法使用CGPointMake将视图(文本框)居中。我知道textBox.center=self.view.center;将使视图居中,但我不知道CGPointMake为什么不工作。我用的是斯威夫特 textBox.font = UIFont.systemFontOfSize(15) textBox.keyboardType = UIKeyboardType.Default textBox.textAlignment = NS

我正在开发一个基本的应用程序,由于某些原因,我无法使用CGPointMake将视图(文本框)居中。我知道textBox.center=self.view.center;将使视图居中,但我不知道CGPointMake为什么不工作。我用的是斯威夫特

    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)

你可以用这段代码来说明这一点

textBox.center = CGPointMake(187.5, 333.5);
CGPointMake(187.5333.5)
但是您没有将文本框的中心指定给这一点。 所以使用这个代码

textBox.center = CGPointMake(187.5, 333.5);
CGPointMake(187.5333.5)
未分配给文本框的任何属性。你确定?