相关疑难解决方法(0)

swift playground UITextField产生的键盘太大了

Swift在Mac OS的操场上.当用户点击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()
Run Code Online (Sandbox Code Playgroud)

截图 在此输入图像描述

keyboard uitextfield swift-playground

9
推荐指数
1
解决办法
1629
查看次数

标签 统计

keyboard ×1

swift-playground ×1

uitextfield ×1