【发布时间】:2015-11-02 08:19:43
【问题描述】:
我的故事板中有一个初始视图控制器,代码如下:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let customview = customUI()
textField.inputView = customview.view
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
在 customUI 类中我有这个代码:
import UIKit
class customUI : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
然后我在情节提要中创建另一个 viewController 并将该类设置为 customUI 类。然后我在情节提要中选择它的背景颜色为蓝色。
然后我运行模拟器,然后点击 textField。它加载纯灰色区域而不是我设置的蓝色背景。
为什么?如何解决这个问题?我是 Xcode 的 UI 新手。
有人在 Objective-C 中讨论过这个问题,但我只知道 swift,请用 swift 给我详细的解释。
【问题讨论】:
-
我认为你应该看看这篇文章:stackoverflow.com/questions/27276561/…
标签: ios swift uiviewcontroller