Ios CGPoint无法正确定位UIView
我正在开发一个基本的应用程序,由于某些原因,我无法使用CGPointMake将视图(文本框)居中。我知道textBox.center=self.view.center;将使视图居中,但我不知道CGPointMake为什么不工作。我用的是斯威夫特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
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)
未分配给文本框的任何属性。你确定?