textfield.returnKeyTYpe = UIReturnKeyDone
因此,以上使我的鍵盤上的Return按鈕說完成。我在UIKeyBoard上看到了帶有藍色按鈕的應用程序。這足夠簡單嗎?如何更改返回鍵的背景顏色?UIKeyBoard返回按鈕UIReturnKeyDone
textfield.returnKeyTYpe = UIReturnKeyDone
因此,以上使我的鍵盤上的Return按鈕說完成。我在UIKeyBoard上看到了帶有藍色按鈕的應用程序。這足夠簡單嗎?如何更改返回鍵的背景顏色?UIKeyBoard返回按鈕UIReturnKeyDone
我不完全確定你可以,如果你能我認爲你可能需要滾動自己的鍵盤或使用無證方法。或者,您可以在按鈕上繪製自己的視圖,並簡單地對用戶觸摸進行透明處理。 This article可能會幫助你。
textfield.returnKeyType = UIReturnKeyGo;
下面是斯威夫特,沒有工作的代碼:
extension ViewController {
func subviewsOfView(view : UIView, withType type:NSString) -> NSArray {
let prefix = NSString(format: "<%@",type) as String
let subViewsArray = NSMutableArray()
for subview in view.subviews {
let tempArray = subviewsOfView(subview, withType: type)
for view in tempArray {
subViewsArray.addObject(view)
}
}
if view.description.hasPrefix(prefix) {
subViewsArray.addObject(view)
}
return NSArray(array: subViewsArray)
}
func addColorToUIKeyboardButton() {
for keyboardWindow in UIApplication.sharedApplication().windows {
for keyboard in keyboardWindow.subviews {
for view in self.subviewsOfView(keyboard, withType: "UIKBKeyplaneView") {
let newView = UIView(frame: (self.subviewsOfView(keyboard, withType: "UIKBKeyView").lastObject as! UIView).frame)
newView.frame = CGRectMake(newView.frame.origin.x + 2, newView.frame.origin.y + 1, newView.frame.size.width - 4, newView.frame.size.height - 3)
newView.backgroundColor = UIColor.redColor() //Or whatever color you want
newView.layer.cornerRadius = 4.0
view.insertSubview(newView, belowSubview: self.subviewsOfView(keyboard, withType: "UIKBKeyView").lastObject as! UIView)
}
}
}
}
}
注意:請務必與addColorToUIKeyboardButton()
的任何實例之前鍵盤是可見的? __ – kennytm 2010-03-20 06:22:03