【发布时间】:2018-04-02 17:22:19
【问题描述】:
Mac OS 上的 Playground 中的 Swift。当用户在 UItextfield 中单击时,会生成一个键盘,但与视图相比它非常大,并且只有前几个键可用。
小例子:
import UIKit
import PlaygroundSupport
class TesterViewController : UIViewController {
var testTextField : UITextField!
override func loadView() {
let view = UIView()
view.backgroundColor = .white
testTextField = UITextField()
testTextField.borderStyle = .roundedRect
testTextField.text = ""
view.addSubview(testTextField)
testTextField.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
testTextField.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
testTextField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
])
self.view = view
}
}
PlaygroundPage.current.liveView = TesterViewController()
【问题讨论】:
标签: keyboard uitextfield swift-playground