溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iOS自定義鍵盤

發(fā)布時間:2020-08-19 05:24:43 來源:網(wǎng)絡 閱讀:769 作者:卓行天下 欄目:移動開發(fā)

對于有輸入功能的控件,例如UITextField,可以給控件的inputView屬性賦值,實現(xiàn)自定義鍵盤的功能

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 300)];UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10, 10, 50, 50)];
[button setTitle:@"1" forState:UIControlStateNormal];
button.backgroundColor = [UIColor whiteColor];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[view addSubview:button];

[button addTarget:self action:@selector(touchAction) forControlEvents:UIControlEventTouchUpInside];

_textField.inputView = view;

點擊下載DEMO

也可以給控件的inputAccessoryView賦值UIToolbar的對象設置工具條。

如果結合第三方鍵盤監(jiān)聽事件的庫IQKeyboard的話,效果更好。



文/Fatm(簡書作者)
原文鏈接:http://www.jianshu.com/p/dee8ef45a741
著作權歸作者所有,轉載請聯(lián)系作者獲得授權,并標注“簡書作者”。


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。

AI