- 숫자 값을 입력받을 수 있는 Number Keyboard
UIInputView
를 기반으로 제작함
- IV-Drop을 만들면서 Number Keyboard에 대한 요구사항 이 있어서 제작함.
- Style presets 지원
- 5가지의 Layout을 제공함
- 버튼의 모양 선택가능
- 4 종류의 Appearance 제공
- Sound 지원
- iOS의 키보드 Sound가 Delete 키와 일반 키 소리가 다른 것을 발견하여 각각 다르게 만들었음
- Sound Source는 Simulator에서 추출함
- Delete 버튼 long press 지원
- long press 시, 일정한 간격으로 반복적으로 호출되어 실행된다.
- Swift and Objective-C compatability
- Written in Objective-C
- MGUNumKeyboard (iOS)
- IV-Drop을 만들면서 Number Keyboard에 대한 요구사항 이 있어서 제작함.
Standard Style | Low Height Style | IV-Drop에서 사용 예 | IV-Drop에서 사용 예 |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Default Configuration
Standard1 | Standard1 Hide Done |
Standard2 | Low Height Style1 | Low Height Style2 | |
---|---|---|---|---|---|
Rounded | ![]() |
![]() |
![]() |
![]() |
![]() |
Rect | ![]() |
![]() |
![]() |
![]() |
![]() |
Forge Configuration
Standard1 | Standard1 Hide Done |
Standard2 | Low Height Style1 | Low Height Style2 | |
---|---|---|---|---|---|
Rounded | ![]() |
![]() |
![]() |
![]() |
![]() |
Rect | ![]() |
![]() |
![]() |
![]() |
![]() |
DarkBlue Configuration
Standard1 | Standard1 Hide Done |
Standard2 | Low Height Style1 | Low Height Style2 | |
---|---|---|---|---|---|
Rounded | ![]() |
![]() |
![]() |
![]() |
![]() |
Rect | ![]() |
![]() |
![]() |
![]() |
![]() |
Blue Configuration
Standard1 | Standard1 Hide Done |
Standard2 | Low Height Style1 | Low Height Style2 | |
---|---|---|---|---|---|
Rounded | ![]() |
![]() |
![]() |
![]() |
![]() |
Rect | ![]() |
![]() |
![]() |
![]() |
![]() |
Swift
let keyboard = MGUNumKeyboard(frame: .zero,
locale: nil,
layoutType: .lowHeightStyle1,
configuration: MGUNumKeyboardConfiguration.darkBlue())
keyboard.delegate = self
// keyboard.allowsDoneButton = true //! MGUNumKeyboardLayoutTypeStandard2에서는 아무런 효과가 없다.
keyboard.roundedButtonShape = false
keyboard.normalSoundPlayBlock = sound?.playSoundKeyPress
keyboard.deleteSoundPlayBlock = sound?.playSoundKeyDelete
keyboard.keyInput = privateTextField // self.textField.inputView = keyboard; 이렇게 설정 금지.
self.privateTextField.isUserInteractionEnabled = false
//! self.textField.alpha = 0.0f; <- 이렇게 실전에서는 처리할 것이다.
keyboard.soundOn = true
privateTextField.addTarget(self, action:#selector(textFieldDidChange(_:)), for: .editingChanged)
Objective-C
MGUNumKeyboard *keyboard =
[[MGUNumKeyboard alloc] initWithFrame:CGRectZero
locale:nil
layoutType:MGUNumKeyboardLayoutTypeLowHeightStyle2
configuration:[MGUNumKeyboardConfiguration forgeConfiguration]];
keyboard.delegate = self;
// keyboard.allowsDoneButton = YES; //! LowHeightStyle에서는 아무런 효과가 없다.
keyboard.roundedButtonShape = YES;
keyboard.normalSoundPlayBlock = self.sound.playSoundKeyPress;
keyboard.deleteSoundPlayBlock = self.sound.playSoundKeyDelete;
keyboard.keyInput = self.privateTextField; // self.textField.inputView = keyboard; 이렇게 설정 금지.
self.privateTextField.userInteractionEnabled = NO;
//! self.textField.alpha = 0.0f; <- 이렇게 실전에서는 처리할 것이다.
keyboard.soundOn = YES;
[self.privateTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- 키보드의 레이아웃을 위한 설계도
UIInputView
를 기반으로 제작하여,UITextField
의inputView
프라퍼티에MGUNumKeyboard
를 설정하면 text field가 퍼스트 리스폰더가 되었을 때 키보드가 올라올 수도 있지만, 여기까지는 테스트하지 않았다.- 커스텀 input view 또는 키보드 악세사리 view에서 키보드 소리를 가져오기 위해서는 다음과 같은 설정이 필요하다.
UIInputViewAudioFeedback
프로토콜을 상속받고,enableInputClicksWhenVisible
메서드(프라퍼티)를 true로 설정한다.- 소리를 원하는 곳에
[[UIDevice currentDevice] playInputClick];
를 호출하라.
sonkoni(손관현), isomorphic111@gmail.com
This project is released under the MIT License. See LICENSE for more information.