Skip to content

Latest commit

 

History

History

MGUNumKeyboard

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

MGUNumKeyboard

Swift Objective-C
iOS

MGUNumKeyboard

  • 숫자 값을 입력받을 수 있는 Number Keyboard
    • UIInputView 를 기반으로 제작함
  • IV-Drop을 만들면서 Number Keyboard에 대한 요구사항 이 있어서 제작함.

Features

  • 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

Preview

  • MGUNumKeyboard (iOS)
    • IV-Drop을 만들면서 Number Keyboard에 대한 요구사항 이 있어서 제작함.
Standard Style Low Height Style IV-Drop에서 사용 예 IV-Drop에서 사용 예

Presets and Styles

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

Usage

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];

Documentation

  • 키보드의 레이아웃을 위한 설계도

  • UIInputView 를 기반으로 제작하여, UITextFieldinputView 프라퍼티에 MGUNumKeyboard를 설정하면 text field가 퍼스트 리스폰더가 되었을 때 키보드가 올라올 수도 있지만, 여기까지는 테스트하지 않았다.
  • 커스텀 input view 또는 키보드 악세사리 view에서 키보드 소리를 가져오기 위해서는 다음과 같은 설정이 필요하다.
    1. UIInputViewAudioFeedback 프로토콜을 상속받고, enableInputClicksWhenVisible 메서드(프라퍼티)를 true로 설정한다.
    2. 소리를 원하는 곳에 [[UIDevice currentDevice] playInputClick];를 호출하라.

Author

sonkoni(손관현), isomorphic111@gmail.com

License

This project is released under the MIT License. See LICENSE for more information.