├── .gitignore
├── .travis.yml
├── Example
├── Podfile
├── Podfile.lock
├── Pods
│ ├── Local Podspecs
│ │ └── YWKeyboardKit.podspec.json
│ ├── Manifest.lock
│ ├── Pods.xcodeproj
│ │ └── project.pbxproj
│ └── Target Support Files
│ │ ├── Pods-YWKeyboardKit_Example
│ │ ├── Pods-YWKeyboardKit_Example-Info.plist
│ │ ├── Pods-YWKeyboardKit_Example-acknowledgements.markdown
│ │ ├── Pods-YWKeyboardKit_Example-acknowledgements.plist
│ │ ├── Pods-YWKeyboardKit_Example-dummy.m
│ │ ├── Pods-YWKeyboardKit_Example-frameworks.sh
│ │ ├── Pods-YWKeyboardKit_Example-umbrella.h
│ │ ├── Pods-YWKeyboardKit_Example.debug.xcconfig
│ │ ├── Pods-YWKeyboardKit_Example.modulemap
│ │ └── Pods-YWKeyboardKit_Example.release.xcconfig
│ │ ├── Pods-YWKeyboardKit_Tests
│ │ ├── Pods-YWKeyboardKit_Tests-Info.plist
│ │ ├── Pods-YWKeyboardKit_Tests-acknowledgements.markdown
│ │ ├── Pods-YWKeyboardKit_Tests-acknowledgements.plist
│ │ ├── Pods-YWKeyboardKit_Tests-dummy.m
│ │ ├── Pods-YWKeyboardKit_Tests-umbrella.h
│ │ ├── Pods-YWKeyboardKit_Tests.debug.xcconfig
│ │ ├── Pods-YWKeyboardKit_Tests.modulemap
│ │ └── Pods-YWKeyboardKit_Tests.release.xcconfig
│ │ └── YWKeyboardKit
│ │ ├── ResourceBundle-YWKeyboardKit-YWKeyboardKit-Info.plist
│ │ ├── YWKeyboardKit-Info.plist
│ │ ├── YWKeyboardKit-dummy.m
│ │ ├── YWKeyboardKit-prefix.pch
│ │ ├── YWKeyboardKit-umbrella.h
│ │ ├── YWKeyboardKit.debug.xcconfig
│ │ ├── YWKeyboardKit.modulemap
│ │ └── YWKeyboardKit.release.xcconfig
├── Tests
│ ├── Tests-Info.plist
│ ├── Tests-Prefix.pch
│ ├── Tests.m
│ └── en.lproj
│ │ └── InfoPlist.strings
├── YWKeyboardKit.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── YWKeyboardKit-Example.xcscheme
├── YWKeyboardKit.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── YWKeyboardKit
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── eyboardKit@2x.png
│ │ └── eyboardKit@3x.png
│ ├── Contents.json
│ ├── icon_eye.imageset
│ │ ├── Contents.json
│ │ ├── icon_eye@2x.png
│ │ └── icon_eye@3x.png
│ ├── icon_eyeclose.imageset
│ │ ├── Contents.json
│ │ ├── icon_eyeclose@2x.png
│ │ └── icon_eyeclose@3x.png
│ ├── icon_guideblue.imageset
│ │ ├── Contents.json
│ │ ├── icon_guideblue@2x.png
│ │ └── icon_guideblue@3x.png
│ └── logo.imageset
│ │ ├── Contents.json
│ │ ├── logo@2x.png
│ │ └── logo@3x.png
│ ├── YWAppDelegate.h
│ ├── YWAppDelegate.m
│ ├── YWKeyboardKit-Info.plist
│ ├── YWKeyboardKit-Prefix.pch
│ ├── YWViewController.h
│ ├── YWViewController.m
│ ├── en.lproj
│ └── InfoPlist.strings
│ └── main.m
├── LICENSE
├── README.md
├── YWKeyboardKit.podspec
├── YWKeyboardKit
├── Assets
│ ├── .gitkeep
│ └── YWKeyBoardAsset.xcassets
│ │ ├── Contents.json
│ │ ├── yw_keyboard_over.imageset
│ │ ├── Contents.json
│ │ ├── key_over@2x-1.png
│ │ ├── key_over@2x.png
│ │ ├── key_over@3x-1.png
│ │ └── key_over@3x.png
│ │ ├── yw_keyboard_up1_acc.imageset
│ │ ├── Contents.json
│ │ ├── yw_keyboard_up1_acc@2x.png
│ │ └── yw_keyboard_up1_acc@3x.png
│ │ └── yw_keyboard_up_acc.imageset
│ │ ├── Contents.json
│ │ ├── yw_keyboard_up_acc@2x-1.png
│ │ ├── yw_keyboard_up_acc@2x.png
│ │ ├── yw_keyboard_up_acc@3x-1.png
│ │ └── yw_keyboard_up_acc@3x.png
└── Classes
│ ├── .gitkeep
│ ├── IdCard
│ ├── YWIdCardKeyboardView.h
│ └── YWIdCardKeyboardView.m
│ ├── InputToolbar
│ ├── YWInputToolbar.h
│ └── YWInputToolbar.m
│ ├── KeyboardButton
│ ├── YWKeyboardButton.h
│ ├── YWKeyboardButton.m
│ ├── YWTipUpView.h
│ └── YWTipUpView.m
│ ├── LicensePlate
│ ├── YWLicensePlateView.h
│ ├── YWLicensePlateView.m
│ ├── YWProvinceLicensePlatePrefixView.h
│ └── YWProvinceLicensePlatePrefixView.m
│ ├── NumPad
│ ├── YWNumPadKeyboardView.h
│ └── YWNumPadKeyboardView.m
│ ├── NumSpecChara
│ ├── YWNumSpencCharaKeyboardView.h
│ └── YWNumSpencCharaKeyboardView.m
│ └── TurtleBezierPath
│ ├── TurtleBezierPath.h
│ └── TurtleBezierPath.m
├── _Pods.xcodeproj
└── image_re
├── id_card_1@2x.png
├── id_card_2@2x.png
├── num_char1@2x.png
├── num_char2@2x.png
├── num_pad_1@2x.png
├── num_pad_2@2x.png
├── plate_1@2x.png
├── plate_2@2x.png
└── plate_3@2x.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata/
15 | *.xccheckout
16 | profile
17 | *.moved-aside
18 | DerivedData
19 | *.hmap
20 | *.ipa
21 |
22 | # Bundler
23 | .bundle
24 |
25 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
26 | # Carthage/Checkouts
27 |
28 | Carthage/Build
29 |
30 | # We recommend against adding the Pods directory to your .gitignore. However
31 | # you should judge for yourself, the pros and cons are mentioned at:
32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
33 | #
34 | # Note: if you ignore the Pods directory, make sure to uncomment
35 | # `pod install` in .travis.yml
36 | #
37 | # Pods/
38 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # references:
2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/
3 | # * https://github.com/supermarin/xcpretty#usage
4 |
5 | osx_image: xcode7.3
6 | language: objective-c
7 | # cache: cocoapods
8 | # podfile: Example/Podfile
9 | # before_install:
10 | # - gem install cocoapods # Since Travis is not always on latest version
11 | # - pod install --project-directory=Example
12 | script:
13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/YWKeyboardKit.xcworkspace -scheme YWKeyboardKit-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
14 | - pod lib lint
15 |
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | platform :ios, '9.0'
4 |
5 | target 'YWKeyboardKit_Example' do
6 | pod 'YWKeyboardKit', :path => '../'
7 | # pod 'YWKeyboardKit/LicensePlate', :path => '../'
8 | # pod 'YWKeyboardKit/InputToolbar', :path => '../'
9 | # pod 'YWKeyboardKit/IdCard', :path => '../'
10 | # pod 'YWKeyboardKit/NumPad', :path => '../'
11 | # pod 'YWKeyboardKit/NumSpecChara', :path => '../'
12 |
13 |
14 |
15 | target 'YWKeyboardKit_Tests' do
16 | inherit! :search_paths
17 |
18 |
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - YWKeyboardKit (0.1.9):
3 | - YWKeyboardKit/IdCard (= 0.1.9)
4 | - YWKeyboardKit/InputToolbar (= 0.1.9)
5 | - YWKeyboardKit/KeyboardButton (= 0.1.9)
6 | - YWKeyboardKit/LicensePlate (= 0.1.9)
7 | - YWKeyboardKit/NumPad (= 0.1.9)
8 | - YWKeyboardKit/NumSpecChara (= 0.1.9)
9 | - YWKeyboardKit/TurtleBezierPath (= 0.1.9)
10 | - YWKeyboardKit/IdCard (0.1.9):
11 | - YWKeyboardKit/KeyboardButton
12 | - YWKeyboardKit/InputToolbar (0.1.9)
13 | - YWKeyboardKit/KeyboardButton (0.1.9):
14 | - YWKeyboardKit/TurtleBezierPath
15 | - YWKeyboardKit/LicensePlate (0.1.9):
16 | - YWKeyboardKit/KeyboardButton
17 | - YWKeyboardKit/NumPad (0.1.9):
18 | - YWKeyboardKit/KeyboardButton
19 | - YWKeyboardKit/NumSpecChara (0.1.9):
20 | - YWKeyboardKit/KeyboardButton
21 | - YWKeyboardKit/TurtleBezierPath (0.1.9)
22 |
23 | DEPENDENCIES:
24 | - YWKeyboardKit (from `../`)
25 |
26 | EXTERNAL SOURCES:
27 | YWKeyboardKit:
28 | :path: "../"
29 |
30 | SPEC CHECKSUMS:
31 | YWKeyboardKit: 02a8002a911d5d7b13e83e72ccef74de59c713ff
32 |
33 | PODFILE CHECKSUM: 33d8266cb882b1986fd31453427bfa69bfb4315c
34 |
35 | COCOAPODS: 1.11.3
36 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/YWKeyboardKit.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "YWKeyboardKit",
3 | "version": "0.1.9",
4 | "summary": "自定义键盘",
5 | "description": "车牌输入的键盘(省份编号、字母、数字),自定义身份证键盘,自定义有效数字键盘,自定义纯数字键盘",
6 | "homepage": "https://github.com/flyOfYW/YWKeyboardKit",
7 | "license": {
8 | "type": "MIT",
9 | "file": "LICENSE"
10 | },
11 | "authors": {
12 | "yw": "1498627884@qq.com"
13 | },
14 | "source": {
15 | "git": "https://github.com/flyOfYW/YWKeyboardKit.git",
16 | "tag": "0.1.9"
17 | },
18 | "platforms": {
19 | "ios": "9.0"
20 | },
21 | "resource_bundles": {
22 | "YWKeyboardKit": [
23 | "YWKeyboardKit/Assets/*.xcassets"
24 | ]
25 | },
26 | "subspecs": [
27 | {
28 | "name": "TurtleBezierPath",
29 | "source_files": "YWKeyboardKit/Classes/TurtleBezierPath/*.{h,m}"
30 | },
31 | {
32 | "name": "KeyboardButton",
33 | "source_files": "YWKeyboardKit/Classes/KeyboardButton/*.{h,m}",
34 | "dependencies": {
35 | "YWKeyboardKit/TurtleBezierPath": [
36 |
37 | ]
38 | }
39 | },
40 | {
41 | "name": "LicensePlate",
42 | "source_files": "YWKeyboardKit/Classes/LicensePlate/*.{h,m}",
43 | "dependencies": {
44 | "YWKeyboardKit/KeyboardButton": [
45 |
46 | ]
47 | },
48 | "resource_bundles": {
49 | "YWKeyboardKit": [
50 | "YWKeyboardKit/Assets/*.xcassets"
51 | ]
52 | }
53 | },
54 | {
55 | "name": "InputToolbar",
56 | "source_files": "YWKeyboardKit/Classes/InputToolbar/*.{h,m}"
57 | },
58 | {
59 | "name": "IdCard",
60 | "source_files": "YWKeyboardKit/Classes/IdCard/*.{h,m}",
61 | "dependencies": {
62 | "YWKeyboardKit/KeyboardButton": [
63 |
64 | ]
65 | },
66 | "resource_bundles": {
67 | "YWKeyboardKit": [
68 | "YWKeyboardKit/Assets/*.xcassets"
69 | ]
70 | }
71 | },
72 | {
73 | "name": "NumPad",
74 | "source_files": "YWKeyboardKit/Classes/NumPad/*.{h,m}",
75 | "dependencies": {
76 | "YWKeyboardKit/KeyboardButton": [
77 |
78 | ]
79 | },
80 | "resource_bundles": {
81 | "YWKeyboardKit": [
82 | "YWKeyboardKit/Assets/*.xcassets"
83 | ]
84 | }
85 | },
86 | {
87 | "name": "NumSpecChara",
88 | "source_files": "YWKeyboardKit/Classes/NumSpecChara/*",
89 | "dependencies": {
90 | "YWKeyboardKit/KeyboardButton": [
91 |
92 | ]
93 | },
94 | "resource_bundles": {
95 | "YWKeyboardKit": [
96 | "YWKeyboardKit/Assets/*.xcassets"
97 | ]
98 | }
99 | }
100 | ]
101 | }
102 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - YWKeyboardKit (0.1.9):
3 | - YWKeyboardKit/IdCard (= 0.1.9)
4 | - YWKeyboardKit/InputToolbar (= 0.1.9)
5 | - YWKeyboardKit/KeyboardButton (= 0.1.9)
6 | - YWKeyboardKit/LicensePlate (= 0.1.9)
7 | - YWKeyboardKit/NumPad (= 0.1.9)
8 | - YWKeyboardKit/NumSpecChara (= 0.1.9)
9 | - YWKeyboardKit/TurtleBezierPath (= 0.1.9)
10 | - YWKeyboardKit/IdCard (0.1.9):
11 | - YWKeyboardKit/KeyboardButton
12 | - YWKeyboardKit/InputToolbar (0.1.9)
13 | - YWKeyboardKit/KeyboardButton (0.1.9):
14 | - YWKeyboardKit/TurtleBezierPath
15 | - YWKeyboardKit/LicensePlate (0.1.9):
16 | - YWKeyboardKit/KeyboardButton
17 | - YWKeyboardKit/NumPad (0.1.9):
18 | - YWKeyboardKit/KeyboardButton
19 | - YWKeyboardKit/NumSpecChara (0.1.9):
20 | - YWKeyboardKit/KeyboardButton
21 | - YWKeyboardKit/TurtleBezierPath (0.1.9)
22 |
23 | DEPENDENCIES:
24 | - YWKeyboardKit (from `../`)
25 |
26 | EXTERNAL SOURCES:
27 | YWKeyboardKit:
28 | :path: "../"
29 |
30 | SPEC CHECKSUMS:
31 | YWKeyboardKit: 02a8002a911d5d7b13e83e72ccef74de59c713ff
32 |
33 | PODFILE CHECKSUM: 33d8266cb882b1986fd31453427bfa69bfb4315c
34 |
35 | COCOAPODS: 1.11.3
36 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## YWKeyboardKit
5 |
6 | Copyright (c) 2020 yw <1498627884@qq.com>
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 | Generated by CocoaPods - https://cocoapods.org
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2020 yw <1498627884@qq.com>
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | License
38 | MIT
39 | Title
40 | YWKeyboardKit
41 | Type
42 | PSGroupSpecifier
43 |
44 |
45 | FooterText
46 | Generated by CocoaPods - https://cocoapods.org
47 | Title
48 |
49 | Type
50 | PSGroupSpecifier
51 |
52 |
53 | StringsTable
54 | Acknowledgements
55 | Title
56 | Acknowledgements
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_YWKeyboardKit_Example : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_YWKeyboardKit_Example
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | set -u
4 | set -o pipefail
5 |
6 | function on_error {
7 | echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
8 | }
9 | trap 'on_error $LINENO' ERR
10 |
11 | if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
12 | # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
13 | # frameworks to, so exit 0 (signalling the script phase was successful).
14 | exit 0
15 | fi
16 |
17 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
18 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
19 |
20 | COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
21 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
22 | BCSYMBOLMAP_DIR="BCSymbolMaps"
23 |
24 |
25 | # This protects against multiple targets copying the same framework dependency at the same time. The solution
26 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
27 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
28 |
29 | # Copies and strips a vendored framework
30 | install_framework()
31 | {
32 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
33 | local source="${BUILT_PRODUCTS_DIR}/$1"
34 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
35 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
36 | elif [ -r "$1" ]; then
37 | local source="$1"
38 | fi
39 |
40 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
41 |
42 | if [ -L "${source}" ]; then
43 | echo "Symlinked..."
44 | source="$(readlink "${source}")"
45 | fi
46 |
47 | if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then
48 | # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied
49 | find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do
50 | echo "Installing $f"
51 | install_bcsymbolmap "$f" "$destination"
52 | rm "$f"
53 | done
54 | rmdir "${source}/${BCSYMBOLMAP_DIR}"
55 | fi
56 |
57 | # Use filter instead of exclude so missing patterns don't throw errors.
58 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
59 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
60 |
61 | local basename
62 | basename="$(basename -s .framework "$1")"
63 | binary="${destination}/${basename}.framework/${basename}"
64 |
65 | if ! [ -r "$binary" ]; then
66 | binary="${destination}/${basename}"
67 | elif [ -L "${binary}" ]; then
68 | echo "Destination binary is symlinked..."
69 | dirname="$(dirname "${binary}")"
70 | binary="${dirname}/$(readlink "${binary}")"
71 | fi
72 |
73 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
74 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
75 | strip_invalid_archs "$binary"
76 | fi
77 |
78 | # Resign the code if required by the build settings to avoid unstable apps
79 | code_sign_if_enabled "${destination}/$(basename "$1")"
80 |
81 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
82 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
83 | local swift_runtime_libs
84 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u)
85 | for lib in $swift_runtime_libs; do
86 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
87 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
88 | code_sign_if_enabled "${destination}/${lib}"
89 | done
90 | fi
91 | }
92 | # Copies and strips a vendored dSYM
93 | install_dsym() {
94 | local source="$1"
95 | warn_missing_arch=${2:-true}
96 | if [ -r "$source" ]; then
97 | # Copy the dSYM into the targets temp dir.
98 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\""
99 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
100 |
101 | local basename
102 | basename="$(basename -s .dSYM "$source")"
103 | binary_name="$(ls "$source/Contents/Resources/DWARF")"
104 | binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}"
105 |
106 | # Strip invalid architectures from the dSYM.
107 | if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then
108 | strip_invalid_archs "$binary" "$warn_missing_arch"
109 | fi
110 | if [[ $STRIP_BINARY_RETVAL == 0 ]]; then
111 | # Move the stripped file into its final destination.
112 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\""
113 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
114 | else
115 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
116 | mkdir -p "${DWARF_DSYM_FOLDER_PATH}"
117 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM"
118 | fi
119 | fi
120 | }
121 |
122 | # Used as a return value for each invocation of `strip_invalid_archs` function.
123 | STRIP_BINARY_RETVAL=0
124 |
125 | # Strip invalid architectures
126 | strip_invalid_archs() {
127 | binary="$1"
128 | warn_missing_arch=${2:-true}
129 | # Get architectures for current target binary
130 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
131 | # Intersect them with the architectures we are building for
132 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
133 | # If there are no archs supported by this binary then warn the user
134 | if [[ -z "$intersected_archs" ]]; then
135 | if [[ "$warn_missing_arch" == "true" ]]; then
136 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
137 | fi
138 | STRIP_BINARY_RETVAL=1
139 | return
140 | fi
141 | stripped=""
142 | for arch in $binary_archs; do
143 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then
144 | # Strip non-valid architectures in-place
145 | lipo -remove "$arch" -output "$binary" "$binary"
146 | stripped="$stripped $arch"
147 | fi
148 | done
149 | if [[ "$stripped" ]]; then
150 | echo "Stripped $binary of architectures:$stripped"
151 | fi
152 | STRIP_BINARY_RETVAL=0
153 | }
154 |
155 | # Copies the bcsymbolmap files of a vendored framework
156 | install_bcsymbolmap() {
157 | local bcsymbolmap_path="$1"
158 | local destination="${BUILT_PRODUCTS_DIR}"
159 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}""
160 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"
161 | }
162 |
163 | # Signs a framework with the provided identity
164 | code_sign_if_enabled() {
165 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
166 | # Use the current code_sign_identity
167 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
168 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
169 |
170 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
171 | code_sign_cmd="$code_sign_cmd &"
172 | fi
173 | echo "$code_sign_cmd"
174 | eval "$code_sign_cmd"
175 | fi
176 | }
177 |
178 | if [[ "$CONFIGURATION" == "Debug" ]]; then
179 | install_framework "${BUILT_PRODUCTS_DIR}/YWKeyboardKit/YWKeyboardKit.framework"
180 | fi
181 | if [[ "$CONFIGURATION" == "Release" ]]; then
182 | install_framework "${BUILT_PRODUCTS_DIR}/YWKeyboardKit/YWKeyboardKit.framework"
183 | fi
184 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
185 | wait
186 | fi
187 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_YWKeyboardKit_ExampleVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_YWKeyboardKit_ExampleVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit/YWKeyboardKit.framework/Headers"
5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
6 | OTHER_LDFLAGS = $(inherited) -framework "YWKeyboardKit"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
10 | PODS_ROOT = ${SRCROOT}/Pods
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_YWKeyboardKit_Example {
2 | umbrella header "Pods-YWKeyboardKit_Example-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Example/Pods-YWKeyboardKit_Example.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit/YWKeyboardKit.framework/Headers"
5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
6 | OTHER_LDFLAGS = $(inherited) -framework "YWKeyboardKit"
7 | PODS_BUILD_DIR = ${BUILD_DIR}
8 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
10 | PODS_ROOT = ${SRCROOT}/Pods
11 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 | Generated by CocoaPods - https://cocoapods.org
4 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Generated by CocoaPods - https://cocoapods.org
18 | Title
19 |
20 | Type
21 | PSGroupSpecifier
22 |
23 |
24 | StringsTable
25 | Acknowledgements
26 | Title
27 | Acknowledgements
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_YWKeyboardKit_Tests : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_YWKeyboardKit_Tests
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
14 | FOUNDATION_EXPORT double Pods_YWKeyboardKit_TestsVersionNumber;
15 | FOUNDATION_EXPORT const unsigned char Pods_YWKeyboardKit_TestsVersionString[];
16 |
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit/YWKeyboardKit.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "YWKeyboardKit"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_YWKeyboardKit_Tests {
2 | umbrella header "Pods-YWKeyboardKit_Tests-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-YWKeyboardKit_Tests/Pods-YWKeyboardKit_Tests.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit"
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit/YWKeyboardKit.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "YWKeyboardKit"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/ResourceBundle-YWKeyboardKit-YWKeyboardKit-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleIdentifier
8 | ${PRODUCT_BUNDLE_IDENTIFIER}
9 | CFBundleInfoDictionaryVersion
10 | 6.0
11 | CFBundleName
12 | ${PRODUCT_NAME}
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 0.1.9
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | ${PRODUCT_BUNDLE_IDENTIFIER}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.1.9
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_YWKeyboardKit : NSObject
3 | @end
4 | @implementation PodsDummy_YWKeyboardKit
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit-umbrella.h:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 | #import "YWIdCardKeyboardView.h"
14 | #import "YWInputToolbar.h"
15 | #import "YWKeyboardButton.h"
16 | #import "YWTipUpView.h"
17 | #import "YWLicensePlateView.h"
18 | #import "YWProvinceLicensePlatePrefixView.h"
19 | #import "YWNumPadKeyboardView.h"
20 | #import "YWNumSpencCharaKeyboardView.h"
21 | #import "TurtleBezierPath.h"
22 |
23 | FOUNDATION_EXPORT double YWKeyboardKitVersionNumber;
24 | FOUNDATION_EXPORT const unsigned char YWKeyboardKitVersionString[];
25 |
26 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit.debug.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit.modulemap:
--------------------------------------------------------------------------------
1 | framework module YWKeyboardKit {
2 | umbrella header "YWKeyboardKit-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/YWKeyboardKit/YWKeyboardKit.release.xcconfig:
--------------------------------------------------------------------------------
1 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
2 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YWKeyboardKit
3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../..
8 | PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
12 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-Prefix.pch:
--------------------------------------------------------------------------------
1 | // The contents of this file are implicitly included at the beginning of every test case source file.
2 |
3 | #ifdef __OBJC__
4 |
5 |
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/Example/Tests/Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWKeyboardKitTests.m
3 | // YWKeyboardKitTests
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | @import XCTest;
10 |
11 | @interface Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation Tests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
36 |
--------------------------------------------------------------------------------
/Example/Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit.xcodeproj/xcshareddata/xcschemes/YWKeyboardKit-Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
66 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
85 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "filename" : "eyboardKit@2x.png",
35 | "idiom" : "iphone",
36 | "scale" : "2x",
37 | "size" : "60x60"
38 | },
39 | {
40 | "filename" : "eyboardKit@3x.png",
41 | "idiom" : "iphone",
42 | "scale" : "3x",
43 | "size" : "60x60"
44 | },
45 | {
46 | "idiom" : "ipad",
47 | "scale" : "1x",
48 | "size" : "20x20"
49 | },
50 | {
51 | "idiom" : "ipad",
52 | "scale" : "2x",
53 | "size" : "20x20"
54 | },
55 | {
56 | "idiom" : "ipad",
57 | "scale" : "1x",
58 | "size" : "29x29"
59 | },
60 | {
61 | "idiom" : "ipad",
62 | "scale" : "2x",
63 | "size" : "29x29"
64 | },
65 | {
66 | "idiom" : "ipad",
67 | "scale" : "1x",
68 | "size" : "40x40"
69 | },
70 | {
71 | "idiom" : "ipad",
72 | "scale" : "2x",
73 | "size" : "40x40"
74 | },
75 | {
76 | "idiom" : "ipad",
77 | "scale" : "1x",
78 | "size" : "76x76"
79 | },
80 | {
81 | "idiom" : "ipad",
82 | "scale" : "2x",
83 | "size" : "76x76"
84 | },
85 | {
86 | "idiom" : "ipad",
87 | "scale" : "2x",
88 | "size" : "83.5x83.5"
89 | },
90 | {
91 | "idiom" : "ios-marketing",
92 | "scale" : "1x",
93 | "size" : "1024x1024"
94 | }
95 | ],
96 | "info" : {
97 | "author" : "xcode",
98 | "version" : 1
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/AppIcon.appiconset/eyboardKit@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/AppIcon.appiconset/eyboardKit@2x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/AppIcon.appiconset/eyboardKit@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/AppIcon.appiconset/eyboardKit@3x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eye.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "filename" : "icon_eye@2x.png",
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "filename" : "icon_eye@3x.png",
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "author" : "xcode",
20 | "version" : 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eye.imageset/icon_eye@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_eye.imageset/icon_eye@2x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eye.imageset/icon_eye@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_eye.imageset/icon_eye@3x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eyeclose.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "filename" : "icon_eyeclose@2x.png",
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "filename" : "icon_eyeclose@3x.png",
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "author" : "xcode",
20 | "version" : 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eyeclose.imageset/icon_eyeclose@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_eyeclose.imageset/icon_eyeclose@2x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_eyeclose.imageset/icon_eyeclose@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_eyeclose.imageset/icon_eyeclose@3x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_guideblue.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "filename" : "icon_guideblue@2x.png",
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "filename" : "icon_guideblue@3x.png",
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "author" : "xcode",
20 | "version" : 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_guideblue.imageset/icon_guideblue@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_guideblue.imageset/icon_guideblue@2x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/icon_guideblue.imageset/icon_guideblue@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/icon_guideblue.imageset/icon_guideblue@3x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/logo.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "filename" : "logo@2x.png",
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "filename" : "logo@3x.png",
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "author" : "xcode",
20 | "version" : 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/logo.imageset/logo@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/logo.imageset/logo@2x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/Images.xcassets/logo.imageset/logo@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/Example/YWKeyboardKit/Images.xcassets/logo.imageset/logo@3x.png
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWAppDelegate.h
3 | // YWKeyboardKit
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface YWAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWAppDelegate.m
3 | // YWKeyboardKit
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | #import "YWAppDelegate.h"
10 |
11 | @implementation YWAppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application
42 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWKeyboardKit-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWKeyboardKit-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | @import UIKit;
15 | @import Foundation;
16 | #endif
17 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWViewController.h
3 | // YWKeyboardKit
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface YWViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/YWViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWViewController.m
3 | // YWKeyboardKit
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | #import "YWViewController.h"
10 | #import
11 | #import
12 | #import
13 |
14 | #import
15 | #import
16 | #import
17 |
18 |
19 | @interface YWViewController ()
20 |
21 | @end
22 |
23 | @implementation YWViewController
24 |
25 | - (void)viewDidLoad
26 | {
27 | [super viewDidLoad];
28 | // Do any additional setup after loading the view, typically from a nib.
29 |
30 |
31 | UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 80 , 34)];
32 | tf.adjustsFontSizeToFitWidth = YES;
33 | tf.placeholder = @"前缀车牌";
34 | tf.tag = 300;
35 | tf.delegate = self;
36 | tf.inputView = [YWProvinceLicensePlatePrefixView getDefalutProvinceKeyBoardView:tf];
37 | tf.borderStyle = UITextBorderStyleRoundedRect;
38 | [self.view addSubview:tf];
39 |
40 | UITextField *tf1 = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 140 , 34)];
41 | tf1.adjustsFontSizeToFitWidth = YES;
42 | tf1.placeholder = @"字母优先可切换车牌";
43 | tf1.inputView = [YWLicensePlateView getEnglishOrProvinceLicensePlate:tf1];
44 | tf1.borderStyle = UITextBorderStyleRoundedRect;
45 | [self.view addSubview:tf1];
46 |
47 | UITextField *tf2 = [[UITextField alloc] initWithFrame:CGRectMake(20, 140, 200 , 34)];
48 | tf2.adjustsFontSizeToFitWidth = YES;
49 | tf2.placeholder = @"一行输入车牌";
50 | tf2.inputView = [YWLicensePlateView getProvinceOrEnglishLicensePlate:tf2];
51 | YWInputToolbar *toolbar = [YWInputToolbar getInputToolbar:tf2];
52 | toolbar.title = @"ETC专用车牌键盘";
53 | tf2.inputAccessoryView = toolbar;
54 | tf2.borderStyle = UITextBorderStyleRoundedRect;
55 | [self.view addSubview:tf2];
56 |
57 | UITextField *tf3 = [[UITextField alloc] initWithFrame:CGRectMake(20, 180, 160 , 34)];
58 | tf3.adjustsFontSizeToFitWidth = YES;
59 | tf3.placeholder = @"身份证键盘";
60 | tf3.inputView = [YWIdCardKeyboardView getIdCardKeyboardDividerView:tf3];
61 | YWInputToolbar *toolbar1 = [YWInputToolbar getInputToolbar:tf3];
62 | toolbar1.title = @"身份证专用键盘";
63 | tf3.inputAccessoryView = toolbar1;
64 | tf3.borderStyle = UITextBorderStyleRoundedRect;
65 | [self.view addSubview:tf3];
66 |
67 | UITextField *tf4 = [[UITextField alloc] initWithFrame:CGRectMake(190, 180, 160 , 34)];
68 | tf4.adjustsFontSizeToFitWidth = YES;
69 | tf4.placeholder = @"身份证键盘";
70 | __block YWIdCardKeyboardView *idCardKeyboardShadowView = [YWIdCardKeyboardView getIdCardKeyboardShadowView:tf4];
71 | tf4.inputView = idCardKeyboardShadowView;
72 | YWInputToolbar *toolbar2 = [YWInputToolbar getInputToolbar:tf4];
73 | toolbar2.leftImageNormal = [UIImage imageNamed:@"icon_eye"];
74 | toolbar2.leftImageSelected = [UIImage imageNamed:@"icon_eyeclose"];
75 | toolbar2.title = @" 身份证专用键盘";
76 | if (@available(iOS 13.0, *)) {
77 | toolbar2.logo = [[UIImage systemImageNamed:@"applelogo"] imageWithTintColor:[UIColor systemBlueColor]];
78 | }
79 | toolbar2.leftCall = ^(id _Nullable obj) {
80 | idCardKeyboardShadowView.downGrayEffect = !idCardKeyboardShadowView.downGrayEffect;
81 | };
82 | tf4.inputAccessoryView = toolbar2;
83 | tf4.borderStyle = UITextBorderStyleRoundedRect;
84 | [self.view addSubview:tf4];
85 |
86 | UITextField *tf5 = [[UITextField alloc] initWithFrame:CGRectMake(20, 220, 160 , 34)];
87 | tf5.adjustsFontSizeToFitWidth = YES;
88 | tf5.placeholder = @"数字键盘带小数点";
89 | YWNumPadKeyboardView * numPadKeyboardView = [YWNumPadKeyboardView getDecimalKeyboardDividerView:tf5];
90 | tf5.inputView = numPadKeyboardView;
91 | tf5.borderStyle = UITextBorderStyleRoundedRect;
92 | [self.view addSubview:tf5];
93 |
94 | UITextField *tf6 = [[UITextField alloc] initWithFrame:CGRectMake(190, 220, 160 , 34)];
95 | tf6.adjustsFontSizeToFitWidth = YES;
96 | tf6.placeholder = @"只能输入有效数字";
97 | YWNumPadKeyboardView * numPadKeyboardView1 = [YWNumPadKeyboardView getDecimalKeyboardShadowView:tf6];
98 | numPadKeyboardView1.effectiveDigit = YES;
99 | tf6.inputView = numPadKeyboardView1;
100 | tf6.borderStyle = UITextBorderStyleRoundedRect;
101 | [self.view addSubview:tf6];
102 |
103 | UITextField *tf7 = [[UITextField alloc] initWithFrame:CGRectMake(20, 260, 160 , 34)];
104 | tf7.adjustsFontSizeToFitWidth = YES;
105 | tf7.placeholder = @"纯数字键盘";
106 | YWNumPadKeyboardView * numPadKeyboardView2 = [YWNumPadKeyboardView getNumKeyboardDividerView:tf7];
107 | tf7.inputView = numPadKeyboardView2;
108 | tf7.borderStyle = UITextBorderStyleRoundedRect;
109 | [self.view addSubview:tf7];
110 |
111 | UITextField *tf8 = [[UITextField alloc] initWithFrame:CGRectMake(190, 260, 160 , 34)];
112 | tf8.adjustsFontSizeToFitWidth = YES;
113 | tf8.placeholder = @"纯数字有效数字";
114 | YWNumPadKeyboardView * numPadKeyboardView3 = [YWNumPadKeyboardView getNumKeyboardShadowView:tf8];
115 | numPadKeyboardView3.effectiveDigit = YES;
116 | tf8.inputView = numPadKeyboardView3;
117 | tf8.borderStyle = UITextBorderStyleRoundedRect;
118 | [self.view addSubview:tf8];
119 |
120 |
121 | UITextField *tf9 = [[UITextField alloc] initWithFrame:CGRectMake(20, 300, 160 , 34)];
122 | tf9.adjustsFontSizeToFitWidth = YES;
123 | tf9.placeholder = @"abc和特殊符号";
124 | YWNumSpencCharaKeyboardView * numCharKeyboardView = [YWNumSpencCharaKeyboardView getCharNumKeyboardView:tf9];
125 | tf9.inputView = numCharKeyboardView;
126 | tf9.borderStyle = UITextBorderStyleRoundedRect;
127 | [self.view addSubview:tf9];
128 |
129 | }
130 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
131 | if (textField.tag == 300) {
132 | textField.text = string;
133 | return NO;
134 | }
135 | return YES;
136 | }
137 |
138 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
139 | [self.view endEditing:YES];
140 | }
141 |
142 | @end
143 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Example/YWKeyboardKit/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // YWKeyboardKit
4 | //
5 | // Created by yw on 12/14/2020.
6 | // Copyright (c) 2020 yw. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 | #import "YWAppDelegate.h"
11 |
12 | int main(int argc, char * argv[])
13 | {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([YWAppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2020 yw <1498627884@qq.com>
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # YWKeyboardKit
2 |
3 | [](https://travis-ci.org/yw/YWKeyboardKit)
4 | [](https://cocoapods.org/pods/YWKeyboardKit)
5 | [](https://cocoapods.org/pods/YWKeyboardKit)
6 | [](https://cocoapods.org/pods/YWKeyboardKit)
7 |
8 |
9 |
10 | 简介
11 | ==============
12 | - 车牌键盘
13 | - 身份键盘
14 | - 数字键盘【支持小数点以及是否有效数字、小数点位数设置】
15 | - 安全键盘
16 | - 26个字母和特殊字符键盘【密码键盘】
17 |
18 | ## Installation
19 |
20 | YWKeyboardKit is available through [CocoaPods](https://cocoapods.org). To install
21 | it, simply add the following line to your Podfile:
22 |
23 | ```ruby
24 | pod 'YWKeyboardKit'//包含所有的键盘
25 | pod 'YWKeyboardKit/LicensePlate'//只引入车牌键盘
26 | pod 'YWKeyboardKit/IdCard'//只引入身份键盘
27 | pod 'YWKeyboardKit/NumPad'//只引入数字键盘
28 | pod 'YWKeyboardKit/NumSpecChara'//只引入字母和特殊符号键盘
29 |
30 | ```
31 |
32 | ## 效果图
33 | 







34 |
35 |
36 | ## Example
37 |
38 | ```
39 | //前缀车牌键盘
40 | UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 100, 80 , 34)];
41 | tf.placeholder = @"前缀车牌";
42 | tf.inputView = [YWProvinceLicensePlatePrefixView getDefalutProvinceKeyBoardView:tf];
43 | [self.view addSubview:tf];
44 |
45 | //省份汉子和字母数字可随意切换的键盘
46 | UITextField *tf2 = [[UITextField alloc] initWithFrame:CGRectMake(20, 140, 200 , 34)];
47 | tf2.placeholder = @"一行输入车牌";
48 | tf2.inputView = [YWLicensePlateView getProvinceOrEnglishLicensePlate:tf2];
49 | [self.view addSubview:tf2];
50 |
51 |
52 | //身份证输入键盘
53 | UITextField *tf4 = [[UITextField alloc] initWithFrame:CGRectMake(190, 180, 160 , 34)];
54 | tf4.placeholder = @"身份证键盘";
55 | __block YWIdCardKeyboardView *idCardKeyboardShadowView = [YWIdCardKeyboardView getIdCardKeyboardShadowView:tf4];
56 | tf4.inputView = idCardKeyboardShadowView;
57 | YWInputToolbar *toolbar2 = [YWInputToolbar getInputToolbar:tf4];
58 | toolbar2.leftImageNormal = [UIImage imageNamed:@"icon_eye"];
59 | toolbar2.leftImageSelected = [UIImage imageNamed:@"icon_eyeclose"];
60 | toolbar2.title = @" 身份证专用键盘";
61 | if (@available(iOS 13.0, *)) {
62 | toolbar2.logo = [[UIImage systemImageNamed:@"applelogo"] imageWithTintColor:[UIColor systemBlueColor]];
63 | }
64 | toolbar2.leftCall = ^(id _Nullable obj) {
65 | idCardKeyboardShadowView.downGrayEffect = !idCardKeyboardShadowView.downGrayEffect;
66 | };
67 | tf4.inputAccessoryView = toolbar2;
68 | [self.view addSubview:tf4];
69 |
70 | ```
71 |
72 | ### 版本更新记录
73 | #### v0.1.7
74 | - 【新增】: 26个字母和特殊符号组合键盘。
75 | - 【新增】: 避免多个键同时被点击。
76 | - 【修复】: 修复暗黑模式适配图标的bug。
77 | #### v0.1.5
78 | - 【新增】: 长按删除效果。
79 | #### v0.1.4
80 | - 【新增】: 数字键盘。
81 | - 【新增】: 自主控制数字的有效性。
82 | - 【新增】: 自主控制小数点的位数。
83 | #### v0.1.3
84 | - 【修复】: 修复在iOS 14.2 不追踪点击效果无效的bug。
85 | #### v0.1.2
86 | - 【新增】: 从项目中整理抽取身份证输入键盘。
87 | - 【新增】: 键盘上的toolbar。
88 | - 【新增】: 点击效果(支持外设)。
89 | #### v0.1.1
90 | - 【新增】: 键盘上的toolbar。
91 | #### v0.1.0
92 | - 【新增】: 从项目中整理抽取车牌键盘。
93 |
94 |
95 | ## Author
96 |
97 | yw, 1498627884@qq.com
98 |
99 | ## License
100 |
101 | YWKeyboardKit is available under the MIT license. See the LICENSE file for more info.
102 |
--------------------------------------------------------------------------------
/YWKeyboardKit.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod lib lint YWKeyboardKit.podspec' to ensure this is a
3 | # valid spec before submitting.
4 | #
5 | # Any lines starting with a # are optional, but their use is encouraged
6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
7 | #
8 |
9 | Pod::Spec.new do |s|
10 | s.name = 'YWKeyboardKit'
11 | s.version = '0.2.1'
12 | s.summary = '自定义键盘'
13 |
14 | # This description is used to generate tags and improve search results.
15 | # * Think: What does it do? Why did you write it? What is the focus?
16 | # * Try to keep it short, snappy and to the point.
17 | # * Write the description between the DESC delimiters below.
18 | # * Finally, don't worry about the indent, CocoaPods strips it!
19 |
20 | s.description = '车牌输入的键盘(省份编号、字母、数字),自定义身份证键盘,自定义有效数字键盘,自定义纯数字键盘'
21 |
22 | s.homepage = 'https://github.com/flyOfYW/YWKeyboardKit'
23 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
24 | s.license = { :type => 'MIT', :file => 'LICENSE' }
25 | s.author = { 'yw' => '1498627884@qq.com' }
26 | s.source = { :git => 'https://github.com/flyOfYW/YWKeyboardKit.git', :tag => s.version.to_s }
27 | # s.social_media_url = 'https://twitter.com/'
28 |
29 | s.ios.deployment_target = '9.0'
30 |
31 | # s.source_files = 'YWKeyboardKit/Classes/**/*'
32 |
33 | #s.resource_bundles = {
34 | # 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.png']
35 | # }
36 |
37 | s.resource_bundles = {
38 | 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.xcassets']
39 | }
40 |
41 | s.subspec 'TurtleBezierPath' do |ns|
42 | ns.source_files = 'YWKeyboardKit/Classes/TurtleBezierPath/*.{h,m}'
43 | end
44 |
45 | s.subspec 'KeyboardButton' do |ns|
46 | ns.source_files = 'YWKeyboardKit/Classes/KeyboardButton/*.{h,m}'
47 | ns.dependency 'YWKeyboardKit/TurtleBezierPath'
48 | end
49 |
50 | s.subspec 'LicensePlate' do |ns|
51 | ns.source_files = 'YWKeyboardKit/Classes/LicensePlate/*.{h,m}'
52 | ns.dependency 'YWKeyboardKit/KeyboardButton'
53 | ns.resource_bundles = {
54 | 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.xcassets']
55 | }
56 | end
57 |
58 | s.subspec 'InputToolbar' do |ns|
59 | ns.source_files = 'YWKeyboardKit/Classes/InputToolbar/*.{h,m}'
60 | end
61 |
62 | s.subspec 'IdCard' do |ns|
63 | ns.source_files = 'YWKeyboardKit/Classes/IdCard/*.{h,m}'
64 | ns.dependency 'YWKeyboardKit/KeyboardButton'
65 | ns.resource_bundles = {
66 | 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.xcassets']
67 | }
68 | end
69 |
70 | s.subspec 'NumPad' do |ns|
71 | ns.source_files = 'YWKeyboardKit/Classes/NumPad/*.{h,m}'
72 | ns.dependency 'YWKeyboardKit/KeyboardButton'
73 | ns.resource_bundles = {
74 | 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.xcassets']
75 | }
76 | end
77 |
78 | s.subspec 'NumSpecChara' do |nc|
79 | nc.source_files = 'YWKeyboardKit/Classes/NumSpecChara/*'
80 | nc.dependency 'YWKeyboardKit/KeyboardButton'
81 | nc.resource_bundles = {
82 | 'YWKeyboardKit' => ['YWKeyboardKit/Assets/*.xcassets']
83 | }
84 | end
85 |
86 |
87 |
88 |
89 | # s.public_header_files = 'Pod/Classes/**/*.h'
90 | # s.frameworks = 'UIKit', 'MapKit'
91 | # s.dependency 'AFNetworking', '~> 2.3'
92 | end
93 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/.gitkeep
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "1x",
10 | "appearances" : [
11 | {
12 | "appearance" : "luminosity",
13 | "value" : "dark"
14 | }
15 | ]
16 | },
17 | {
18 | "idiom" : "universal",
19 | "filename" : "key_over@2x.png",
20 | "scale" : "2x"
21 | },
22 | {
23 | "idiom" : "universal",
24 | "filename" : "key_over@2x-1.png",
25 | "appearances" : [
26 | {
27 | "appearance" : "luminosity",
28 | "value" : "dark"
29 | }
30 | ],
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "universal",
35 | "filename" : "key_over@3x.png",
36 | "scale" : "3x"
37 | },
38 | {
39 | "idiom" : "universal",
40 | "filename" : "key_over@3x-1.png",
41 | "appearances" : [
42 | {
43 | "appearance" : "luminosity",
44 | "value" : "dark"
45 | }
46 | ],
47 | "scale" : "3x"
48 | }
49 | ],
50 | "info" : {
51 | "version" : 1,
52 | "author" : "xcode"
53 | }
54 | }
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@2x-1.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@2x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@3x-1.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_over.imageset/key_over@3x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up1_acc.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "filename" : "yw_keyboard_up1_acc@2x.png",
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "filename" : "yw_keyboard_up1_acc@3x.png",
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "author" : "xcode",
20 | "version" : 1
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up1_acc.imageset/yw_keyboard_up1_acc@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up1_acc.imageset/yw_keyboard_up1_acc@2x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up1_acc.imageset/yw_keyboard_up1_acc@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up1_acc.imageset/yw_keyboard_up1_acc@3x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "appearances" : [
9 | {
10 | "appearance" : "luminosity",
11 | "value" : "dark"
12 | }
13 | ],
14 | "idiom" : "universal",
15 | "scale" : "1x"
16 | },
17 | {
18 | "filename" : "yw_keyboard_up_acc@2x.png",
19 | "idiom" : "universal",
20 | "scale" : "2x"
21 | },
22 | {
23 | "appearances" : [
24 | {
25 | "appearance" : "luminosity",
26 | "value" : "dark"
27 | }
28 | ],
29 | "filename" : "yw_keyboard_up_acc@2x-1.png",
30 | "idiom" : "universal",
31 | "scale" : "2x"
32 | },
33 | {
34 | "filename" : "yw_keyboard_up_acc@3x.png",
35 | "idiom" : "universal",
36 | "scale" : "3x"
37 | },
38 | {
39 | "appearances" : [
40 | {
41 | "appearance" : "luminosity",
42 | "value" : "dark"
43 | }
44 | ],
45 | "filename" : "yw_keyboard_up_acc@3x-1.png",
46 | "idiom" : "universal",
47 | "scale" : "3x"
48 | }
49 | ],
50 | "info" : {
51 | "author" : "xcode",
52 | "version" : 1
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@2x-1.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@2x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@3x-1.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Assets/YWKeyBoardAsset.xcassets/yw_keyboard_up_acc.imageset/yw_keyboard_up_acc@3x.png
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/YWKeyboardKit/Classes/.gitkeep
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/IdCard/YWIdCardKeyboardView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWIdCardKeyboardView.h
3 | // JXNewAirRecharge
4 | //
5 | // Created by yaowei on 2019/10/11.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWIdCardKeyboardView : UIInputView
13 | @property (nonatomic, weak, readonly) id textInput;
14 | /**是否需要按下变灰效果*/
15 | @property (nonatomic, assign ) BOOL downGrayEffect;
16 |
17 | /**分割线形式的键盘*/
18 | + (instancetype)getIdCardKeyboardDividerView:(id)textInput;
19 | /**间隔形式的键盘*/
20 | + (instancetype)getIdCardKeyboardShadowView:(id)textInput;
21 |
22 |
23 | @end
24 |
25 | NS_ASSUME_NONNULL_END
26 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/IdCard/YWIdCardKeyboardView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWIdCardKeyboardView.m
3 | // JXNewAirRecharge
4 | //
5 | // Created by yaowei on 2019/10/11.
6 | //
7 |
8 | #import "YWIdCardKeyboardView.h"
9 | #import
10 |
11 | @interface YWIdCardKeyboardView ()
12 | {
13 | CGFloat _itemWidth;
14 | CGFloat _dividerSpace;
15 | }
16 | @property (nonatomic, weak, readwrite) id textInput;
17 | @property (nonatomic, strong ) NSMutableArray *numList;
18 | @property (nonatomic, strong, nullable) NSBundle *thisBundle;
19 | @property (nonatomic, strong ) UIColor *deleteColor;
20 | @property (nonatomic, assign ) NSInteger cellType;
21 | @property (nonatomic, strong, nullable) NSTimer *timer;
22 | @end
23 |
24 | @implementation YWIdCardKeyboardView
25 |
26 | + (instancetype)getIdCardKeyboardDividerView:(id)textInput{
27 | YWIdCardKeyboardView *kView = [[self alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput cellType:0];
28 | return kView;
29 | }
30 | + (instancetype)getIdCardKeyboardShadowView:(id)textInput{
31 | YWIdCardKeyboardView *kView = [[self alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput cellType:1];
32 | return kView;
33 | }
34 | - (instancetype)initWithFrame:(CGRect)frame
35 | inputViewStyle:(UIInputViewStyle)inputViewStyle
36 | textInput:(id)textInput
37 | cellType:(NSInteger)cellType{
38 | self = [super initWithFrame:frame inputViewStyle:inputViewStyle];
39 | if (self) {
40 | _cellType = cellType;
41 | _dividerSpace = 0.5;
42 | [self sizeToFit];
43 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
44 | _textInput = textInput;
45 | _downGrayEffect = YES;
46 | //赋值触发UI搭建
47 | self.cellType = cellType;
48 | }
49 | return self;
50 | }
51 | //MARK: --- YWKeyboardButtonDelegate ---
52 | - (BOOL)needDownGrayEffect:(YWKeyboardButton *)button{
53 | if (_cellType == 0) {
54 | return _downGrayEffect;
55 | }
56 | if (_cellType == 1) {
57 | return _downGrayEffect;
58 | }
59 | return NO;
60 | }
61 | //MARK: --- 单元格圆角样式的view ---
62 | - (void)createShadowView{
63 | NSInteger lineItem = 3;
64 | CGFloat space = 10;
65 | NSInteger i = 0;
66 | CGFloat top = 10;
67 | CGFloat width = _itemWidth;
68 | CGFloat height = 0.34 * width;
69 | CGFloat leftX = 10;
70 |
71 | for (NSString *kText in self.numList) {
72 | NSInteger index = i % lineItem;
73 | NSInteger page = i / lineItem;
74 | YWKeyboardDownButton *btn = [YWKeyboardDownButton buttonWithType:UIButtonTypeCustom];
75 | CGFloat currentX = index * (width + space) + leftX;
76 | btn.frame = CGRectMake(currentX, top + (height + top) * page, width, height);
77 | if ([kText isEqual:@""]) {
78 | btn.tag = 902;
79 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
80 | btn.keyColor = self.deleteColor;
81 | [self idcard_addLongGesAction:btn];
82 | }
83 | btn.delegate = self;
84 | btn.input = kText;
85 | btn.textInput = _textInput;
86 | [self addSubview:btn];
87 | i ++;
88 | }
89 | }
90 |
91 | //MARK: --- 分割线样式的view ---
92 | - (void)createDividerView{
93 |
94 | NSInteger lineItem = 3;
95 | CGFloat space = _dividerSpace;
96 | NSInteger i = 0;
97 | CGFloat top = 0;
98 | CGFloat width = _itemWidth;
99 | CGFloat height = 0.34 * width;
100 |
101 | for (NSString *kText in self.numList) {
102 | NSInteger index = i % lineItem;
103 | NSInteger page = i / lineItem;
104 | YWKeyboardDownButton *btn = [YWKeyboardDownButton buttonWithType:UIButtonTypeCustom];
105 | CGFloat currentX = index * (width + space);
106 | btn.frame = CGRectMake(currentX, top + (height + space) * page, width, height);
107 | btn.drawShadow = NO;
108 | if ([kText isEqual:@""]) {
109 | btn.tag = 902;
110 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
111 | btn.keyColor = self.deleteColor;
112 | [self idcard_addLongGesAction:btn];
113 | }
114 | btn.delegate = self;
115 | btn.input = kText;
116 | btn.textInput = _textInput;
117 | [self addSubview:btn];
118 | i ++;
119 | }
120 | }
121 | //MARK: --- 长按 delete ----
122 | - (void)idcard_addLongGesAction:(YWKeyboardDownButton *) btn{
123 | UILongPressGestureRecognizer *ges = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(idcard_deleteWithLognGes:)];
124 | [btn addGestureRecognizer:ges];
125 | }
126 |
127 | - (void)idcard_deleteWithLognGes:(UILongPressGestureRecognizer *)sender{
128 | if (sender.state == UIGestureRecognizerStateBegan) {
129 | [self.timer invalidate];
130 | self.timer = nil;
131 | self.timer = [NSTimer timerWithTimeInterval:0.1
132 | target:self
133 | selector:@selector(idcard_deleteAction)
134 | userInfo:nil
135 | repeats:YES];
136 | [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
137 | }else if (sender.state == UIGestureRecognizerStateEnded){
138 | [self.timer invalidate];
139 | self.timer = nil;
140 | }
141 | }
142 | - (void)idcard_deleteAction{
143 | [self.textInput deleteBackward];
144 | }
145 | //MARK: --- load YWKeyboardKit Bundle image ----
146 | - (UIImage *)getImageOnBundleWithImage:(NSString *)imageName{
147 | return [self getImageOnBundle:imageName ofType:@"png"];
148 | }
149 | - (UIImage *)getImageOnBundle:(NSString *)imageName
150 | ofType:(NSString *)type{
151 |
152 | return [UIImage imageNamed:imageName
153 | inBundle:self.thisBundle compatibleWithTraitCollection:nil];
154 |
155 | }
156 |
157 |
158 | - (CGSize)sizeThatFits:(CGSize)size{
159 | CGSize sizeThatFit = [super sizeThatFits:size];
160 | CGFloat lbh = YW_KEYBOARD_TABBARBOTTOM;
161 | if (_cellType == 0) {
162 | _itemWidth = ([UIScreen mainScreen].bounds.size.width - _dividerSpace * 2)/3;
163 | CGFloat height = 0.34 * _itemWidth;
164 | sizeThatFit.height = height * 4 + lbh + _dividerSpace * 3;
165 | }else if(_cellType == 1){
166 | _itemWidth = ([UIScreen mainScreen].bounds.size.width - 40)/3;
167 | CGFloat height = 0.34 * _itemWidth;
168 | sizeThatFit.height = height * 4 + (lbh > 0 ? lbh : 10) + 40;
169 | }
170 | return sizeThatFit;
171 | }
172 |
173 | //MARK: --- getter && setter
174 | - (void)setCellType:(NSInteger)cellType{
175 | _cellType = cellType;
176 | switch (cellType) {
177 | case 0:
178 | [self createDividerView];
179 | break;
180 | case 1:
181 | [self createShadowView];
182 | break;
183 |
184 | default:
185 | break;
186 | }
187 | }
188 | - (NSBundle *)thisBundle{
189 | if (!_thisBundle) {
190 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
191 |
192 | NSURL *url = [bundle URLForResource:@"YWKeyboardKit"
193 | withExtension:@"bundle"];
194 |
195 | _thisBundle = [NSBundle bundleWithURL:url];
196 | }
197 | return _thisBundle;
198 | }
199 |
200 | - (NSMutableArray *)numList{
201 | if (!_numList) {
202 | _numList = [NSMutableArray arrayWithArray:@[
203 | @"1",@"2",@"3",
204 | @"4",@"5",@"6",
205 | @"7",@"8",@"9",
206 | @"X",@"0",@""
207 | ]];
208 | }
209 | return _numList;
210 | }
211 | - (UIColor *)deleteColor{
212 | if (!_deleteColor) {
213 | if (@available(iOS 13.0, *)) {
214 | _deleteColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
215 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
216 | return [UIColor colorWithRed:46.0/255.f green:46.0/255.f blue:46.0/255.f alpha:1];
217 | }else{
218 | return [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
219 | }
220 | }];
221 | } else {
222 | _deleteColor = [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
223 | }
224 | }
225 | return _deleteColor;
226 | }
227 |
228 |
229 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
230 | YWKeyboardButton *btn = [self viewWithTag:902];
231 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
232 | }
233 | @end
234 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/InputToolbar/YWInputToolbar.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWInputToolbar.h
3 | // Pods-YWKeyboardKit_Example
4 | //
5 | // Created by yaowei on 2020/12/17.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWInputToolbar : UIView
13 |
14 | @property (nonatomic, weak, readonly) id textInput;
15 | /**颜色*/
16 | @property (nullable, nonatomic, strong) UIColor *toolbarBarTintColor;
17 | /**左边的图标*/
18 | @property (nullable, nonatomic, strong) UIImage *leftImageNormal;
19 | /**左边的标题*/
20 | @property (nullable, nonatomic, copy ) NSString *leftTitleNormal;
21 | /**左边的图标*/
22 | @property (nullable, nonatomic, strong) UIImage *leftImageSelected;
23 | /**左边的标题*/
24 | @property (nullable, nonatomic, copy ) NSString *leftTitleSelected;
25 | /**标题栏logo*/
26 | @property (nullable, nonatomic, strong) UIImage *logo;
27 | /**标题*/
28 | @property (nullable, nonatomic, copy ) NSString *title;
29 | /**完成*/
30 | @property (nullable, nonatomic, copy ) NSString *done;
31 |
32 | /**”左边“ 点击的回调*/
33 | @property (nullable, nonatomic, copy ) void(^leftCall)(_Nullable id obj);
34 |
35 | /**”完成“ 点击的回调*/
36 | @property (nullable, nonatomic, copy ) void(^doneCall)(_Nullable id obj);
37 |
38 | + (instancetype)getInputToolbar:(id)textInput;
39 |
40 | @end
41 |
42 | NS_ASSUME_NONNULL_END
43 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/InputToolbar/YWInputToolbar.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWInputToolbar.m
3 | // Pods-YWKeyboardKit_Example
4 | //
5 | // Created by yaowei on 2020/12/17.
6 | //
7 |
8 | #import "YWInputToolbar.h"
9 |
10 | @interface YWInputToolbar ()
11 | @property (nonatomic, strong) UIView *topView;
12 | @property (nonatomic, strong) UIButton *leftBarButton;
13 | @property (nonatomic, strong) UIButton *titleBarButton;
14 | @property (nonatomic, strong) UIButton *doneBarButton;
15 | @property (nonatomic, weak, readwrite) id textInput;
16 |
17 | @end
18 |
19 | @implementation YWInputToolbar
20 |
21 |
22 | + (instancetype)getInputToolbar:(id)textInput{
23 | YWInputToolbar *toolbar = [[YWInputToolbar alloc] initWithFrame:CGRectZero];
24 | toolbar.textInput = textInput;
25 | return toolbar;
26 | }
27 | - (void)initialize{
28 | [self sizeToFit];
29 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
30 | [self addSubview:self.topView];
31 | [self addSubview:self.leftBarButton];
32 | [self addSubview:self.titleBarButton];
33 | [self addSubview:self.doneBarButton];
34 | [self barStyleAction];
35 | }
36 |
37 | - (void)barStyleAction{
38 | if (@available(iOS 13.0, *)) {
39 | self.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
40 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
41 | return [UIColor colorWithRed:87.0/255.f green:87.0/255.f blue:87.0/255.f alpha:1];
42 | }else{
43 | return [UIColor colorWithRed:246.0/255.f green:246.0/255.f blue:246/255.f alpha:1];
44 | }
45 | }];
46 | self.topView.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
47 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
48 | return [UIColor colorWithRed:118.0/255.f green:118.0/255.f blue:118.0/255.f alpha:1];
49 | }else{
50 | return [UIColor colorWithRed:230.0/255.f green:230.0/255.f blue:230.0/255.f alpha:1];
51 | }
52 | }];
53 | } else {
54 | self.backgroundColor = [UIColor colorWithRed:246.0/255.f green:246.0/255.f blue:246/255.f alpha:1];
55 |
56 | self.topView.backgroundColor = [UIColor colorWithRed:230.0/255.f green:230.0/255.f blue:230.0/255.f alpha:1];
57 | }
58 |
59 | }
60 |
61 | - (instancetype)initWithFrame:(CGRect)frame{
62 | self = [super initWithFrame:frame];
63 | if (self){
64 | [self initialize];
65 | }
66 | return self;
67 | }
68 |
69 | - (instancetype)initWithCoder:(NSCoder *)coder{
70 | self = [super initWithCoder:coder];
71 | if (self){
72 | [self initialize];
73 | }
74 | return self;
75 | }
76 | - (void)leftAction{
77 | _leftBarButton.selected = !_leftBarButton.selected;
78 | if (_leftCall) {
79 | _leftCall(nil);
80 | }
81 | }
82 | - (void)doneAction{
83 | if ([self.textInput isKindOfClass:[UITextView class]]) {
84 | UITextView *textView = (UITextView *)self.textInput;
85 | [textView resignFirstResponder];
86 | } else if ([self.textInput isKindOfClass:[UITextField class]]) {
87 | UITextField *textField = (UITextField *)self.textInput;
88 | [textField resignFirstResponder];
89 | }
90 | if (_doneCall) {
91 | _doneCall(nil);
92 | }
93 | }
94 | - (void)setLeftImageNormal:(UIImage *)leftImageNormal{
95 | _leftImageNormal = leftImageNormal;
96 | [_leftBarButton setImage:[leftImageNormal imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
97 | }
98 | - (void)setLeftTitleNormal:(NSString *)leftTitleNormal{
99 | _leftTitleNormal = leftTitleNormal;
100 | [_leftBarButton setTitle:leftTitleNormal forState:UIControlStateNormal];
101 | }
102 | - (void)setLeftImageSelected:(UIImage *)leftImageSelected{
103 | _leftImageSelected = leftImageSelected;
104 | [_leftBarButton setImage:[leftImageSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateSelected];
105 | }
106 | - (void)setLeftTitleSelected:(NSString *)leftTitleSelected{
107 | _leftTitleSelected = leftTitleSelected;
108 | [_leftBarButton setTitle:_leftTitleSelected forState:UIControlStateSelected];
109 | }
110 | - (void)setTitle:(NSString *)title{
111 | _title = title;
112 | [_titleBarButton setTitle:title forState:UIControlStateNormal];
113 | [self setNeedsLayout];
114 | }
115 | - (void)setLogo:(UIImage *)logo{
116 | _logo = logo;
117 | [_titleBarButton setImage:[logo imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
118 | }
119 | - (void)setDone:(NSString *)done{
120 | _done = done;
121 | [_doneBarButton setTitle:done forState:UIControlStateNormal];
122 | [self setNeedsLayout];
123 | }
124 |
125 | - (UIButton *)leftBarButton{
126 | if (_leftBarButton == nil) {
127 | _leftBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
128 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
129 | if (@available(iOS 13.0, *)) {
130 | [_leftBarButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
131 | } else
132 | #endif
133 | {
134 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
135 | [_leftBarButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
136 | #endif
137 | }
138 | [_leftBarButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
139 | [_leftBarButton setBackgroundColor:[UIColor clearColor]];
140 | [_leftBarButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
141 | [_leftBarButton addTarget:self action:@selector(leftAction) forControlEvents:UIControlEventTouchUpInside];
142 | }
143 | return _leftBarButton;
144 | }
145 | - (UIButton *)titleBarButton{
146 | if (_titleBarButton == nil) {
147 | _titleBarButton = [UIButton buttonWithType:UIButtonTypeCustom];
148 | _titleBarButton.titleLabel.numberOfLines = 2;
149 | _titleBarButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
150 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
151 | if (@available(iOS 13.0, *)) {
152 | [_titleBarButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
153 | } else
154 | #endif
155 | {
156 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
157 | [_titleBarButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
158 | #endif
159 | }
160 | [_titleBarButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
161 | [_titleBarButton setBackgroundColor:[UIColor clearColor]];
162 | [_titleBarButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
163 | }
164 | return _titleBarButton;
165 | }
166 | - (UIButton *)doneBarButton{
167 | if (_doneBarButton == nil) {
168 | _doneBarButton = [UIButton buttonWithType:UIButtonTypeSystem];
169 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
170 | if (@available(iOS 13.0, *)) {
171 | [_doneBarButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
172 | } else
173 | #endif
174 | {
175 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
176 | [_doneBarButton setTitleColor:[UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
177 | #endif
178 | }
179 | [_doneBarButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
180 | [_doneBarButton setBackgroundColor:[UIColor clearColor]];
181 | [_doneBarButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
182 | [_doneBarButton setTitle:@"完成" forState:UIControlStateNormal];
183 | _doneBarButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
184 | [_doneBarButton addTarget:self action:@selector(doneAction) forControlEvents:UIControlEventTouchUpInside];
185 | }
186 | return _doneBarButton;
187 | }
188 | - (UIView *)topView{
189 | if (!_topView) {
190 | _topView = [UIView new];
191 | }
192 | return _topView;
193 | }
194 |
195 | - (CGSize)sizeThatFits:(CGSize)size{
196 | CGSize sizeThatFit = [super sizeThatFits:size];
197 | sizeThatFit.height = 44;
198 | return sizeThatFit;
199 | }
200 | - (void)layoutSubviews{
201 | [super layoutSubviews];
202 |
203 | CGFloat margin = 16;
204 |
205 | CGSize leftSize = [self.leftBarButton sizeThatFits:CGSizeMake(80, 44)];
206 |
207 | CGSize doneSize = [self.doneBarButton sizeThatFits:CGSizeMake(80, 44)];
208 |
209 |
210 | CGFloat maxWidth = CGRectGetWidth(self.frame) - (margin + leftSize.width) - (margin + doneSize.width) - margin * 2;
211 |
212 | _topView.frame = CGRectMake(0, 0, self.frame.size.width, 1);
213 |
214 | _leftBarButton.frame = CGRectMake(margin, 0, leftSize.width, 44);
215 | _titleBarButton.frame = CGRectMake(CGRectGetMaxX(_leftBarButton.frame) + margin, 0, maxWidth, 44);
216 | _doneBarButton.frame = CGRectMake(CGRectGetMaxX(_titleBarButton.frame) + margin, 0, doneSize.width, 44);
217 | }
218 |
219 | @end
220 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/KeyboardButton/YWKeyboardButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWKeyboardButton.h
3 | // TextKeyBoard
4 | //
5 | // Created by Mr.Yao on 2020/2/27.
6 | // Copyright © 2020 Mr.Yao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //刘海屏底部的高度
12 | #define YW_KEYBOARD_TABBARBOTTOM ({\
13 | CGFloat isBangsScreen = 0; \
14 | if (@available(iOS 11.0, *)) { \
15 | UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
16 | isBangsScreen = window.safeAreaInsets.bottom; \
17 | } \
18 | isBangsScreen; \
19 | })
20 |
21 |
22 |
23 | NS_ASSUME_NONNULL_BEGIN
24 |
25 | typedef NS_ENUM(NSUInteger, YWKeyboardButtonPosition) {
26 | YWKeyboardButtonPositionLeft,
27 | YWKeyboardButtonPositionInner,
28 | YWKeyboardButtonPositionRight
29 | };
30 |
31 | @protocol YWKeyboardButtonDelegate
32 | @optional
33 | /**执行YWKeyboardButton内部的TouchUpInside,YES-继续执行内部的实现,NO-不需要执行(YES:输入字符,NO-不需要输入字符)*/
34 | - (BOOL)interceptorTouchUpInside:(UIButton *)button;
35 |
36 | /// 是否需要点击放大效果
37 | /// @param button 当前操作对象
38 | - (BOOL)needDrawAmplification:(UIButton *)button;
39 |
40 | /// 是否需要按下变灰效果
41 | /// @param button 当前操作对象
42 | - (BOOL)needDownGrayEffect:(UIButton *)button;
43 |
44 | /// 按下的回调
45 | /// @param button 当前操作对象
46 | - (void)handleTouchDownForState:(UIButton *)button;
47 |
48 | @end
49 |
50 | @protocol YWKeyboardButtonDataSource
51 | @optional
52 | /**是否录入有效数字,0-可以随意输入,1-保留一位小数点的有效数字,n-保留n位小数点的有效数字*/
53 | - (NSInteger)isEffectiveDigitForInput:(UIButton *)button;
54 |
55 |
56 | @end
57 |
58 |
59 |
60 |
61 |
62 | @interface YWKeyboardButton : UIButton
63 |
64 | @property (nonatomic, strong) NSString *input;
65 | /**normal selected 不一致*/
66 | @property (nonatomic, strong) NSString *inputSelected;
67 | /**键盘颜色*/
68 | @property (nonatomic, strong) UIColor *keyColor;
69 | /**键盘上的文字颜色*/
70 | @property (nonatomic, strong) UIColor *keyTextColor;
71 | /**底部边距线颜色*/
72 | @property (nonatomic, strong) UIColor *keyShadowColor;
73 | /**按下效果颜色*/
74 | @property (nonatomic, strong) UIColor *downGrayEffectColor;
75 | /**默认YES*/
76 | @property (nonatomic, assign) BOOL drawAmplification;
77 | /**输入框*/
78 | @property (nonatomic, weak) id textInput;
79 |
80 | @property (nonatomic, readonly) YWKeyboardButtonPosition position;
81 |
82 | @property (nonatomic, weak) id delegate;
83 |
84 | @property (nonatomic, copy, nullable) UIImage *bgIconImage;
85 |
86 | @property (nonatomic, copy, nullable) UIImage *iconImage;
87 |
88 | /// 获取当前的文字,由于加入了大小字母
89 | - (NSString *)getCurrentInputText;
90 | @end
91 |
92 |
93 | @interface YWKeyboardDownButton : UIButton
94 |
95 | @property (nonatomic, strong) NSString *input;
96 | /**键盘颜色*/
97 | @property (nonatomic, strong) UIColor *keyColor;
98 | /**键盘上的文字颜色*/
99 | @property (nonatomic, strong) UIColor *keyTextColor;
100 | /**底部边距线颜色*/
101 | @property (nonatomic, strong) UIColor *keyShadowColor;
102 | /**按下效果颜色*/
103 | @property (nonatomic, strong) UIColor *downGrayEffectColor;
104 | /**默认YES*/
105 | @property (nonatomic, assign) BOOL drawShadow;
106 | /**按下变灰效果,默认NO*/
107 | @property (nonatomic, assign) BOOL downGray;
108 | /**特定不需要点击效果*/
109 | @property (nonatomic, assign) BOOL specificNoDown;
110 |
111 | /**输入框*/
112 | @property (nonatomic, weak) id textInput;
113 |
114 | @property (nonatomic, weak) id delegate;
115 |
116 | @property (nonatomic, weak) id dataSource;
117 |
118 | @property (nonatomic, copy, nullable) UIImage *bgIconImage;
119 |
120 | @property (nonatomic, copy, nullable) UIImage *iconImage;
121 |
122 |
123 | @end
124 |
125 |
126 | NS_ASSUME_NONNULL_END
127 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/KeyboardButton/YWKeyboardButton.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWKeyboardButton.m
3 | // TextKeyBoard
4 | //
5 | // Created by Mr.Yao on 2020/2/27.
6 | // Copyright © 2020 Mr.Yao. All rights reserved.
7 | //
8 |
9 | #import "YWKeyboardButton.h"
10 | #import "YWTipUpView.h"
11 |
12 |
13 | @interface YWKeyboardButton ()
14 | {
15 | struct {
16 | unsigned inTouchUpInside : 1;
17 | unsigned amplification : 1;
18 | unsigned touchDownForState : 1;
19 | } _delegateHas;
20 |
21 | }
22 | @property (nonatomic, strong ) YWTipUpView *buttonView;
23 | @property (nonatomic, readwrite ) YWKeyboardButtonPosition position;
24 |
25 | @end
26 |
27 | @implementation YWKeyboardButton
28 |
29 | - (id)initWithFrame:(CGRect)frame{
30 | self = [super initWithFrame:frame];
31 | if (self) {
32 | [self commonInit];
33 | }
34 | return self;
35 | }
36 |
37 | - (instancetype)initWithCoder:(NSCoder *)aDecoder{
38 | self = [super initWithCoder:aDecoder];
39 | if (self) {
40 | [self commonInit];
41 | }
42 | return self;
43 | }
44 | //手指按下按钮的事件
45 | - (void)handleTouchDown{
46 | [[UIDevice currentDevice] playInputClick];
47 | if (_delegateHas.touchDownForState) {
48 | [_delegate handleTouchDownForState:self];
49 | }
50 | if ([self isDrawAmplification]) {//放大效果
51 | [self showInputView];
52 | }
53 | }
54 | - (void)handleTouchUpInside{
55 | BOOL isContinue = YES;
56 | if (_delegateHas.inTouchUpInside) {
57 | isContinue = [_delegate interceptorTouchUpInside:self];
58 | }
59 | if (!isContinue) return;
60 | // [self insertText:self.input];
61 | [self insertText:[self getCurrentInputText]];
62 | if ([self isDrawAmplification]) {
63 | [self hideInputView];
64 | }
65 | }
66 | - (void)showInputView{
67 | [self hideInputView];
68 | self.buttonView = [[YWTipUpView alloc] initWithKeyboardButton:self];
69 | [self.window addSubview:self.buttonView];
70 | }
71 |
72 | - (void)hideInputView{
73 | [self.buttonView removeFromSuperview];
74 | self.buttonView = nil;
75 | [self setNeedsDisplay];
76 | }
77 |
78 | - (void)insertText:(NSString *)text{
79 | BOOL shouldInsertText = YES;
80 |
81 | if ([self.textInput isKindOfClass:[UITextView class]]) {
82 | // Call UITextViewDelegate methods if necessary
83 | UITextView *textView = (UITextView *)self.textInput;
84 | NSRange selectedRange = textView.selectedRange;
85 |
86 | if ([textView.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)]) {
87 | shouldInsertText = [textView.delegate textView:textView
88 | shouldChangeTextInRange:selectedRange
89 | replacementText:text];
90 | }
91 | } else if ([self.textInput isKindOfClass:[UITextField class]]) {
92 | // Call UITextFieldDelgate methods if necessary
93 | UITextField *textField = (UITextField *)self.textInput;
94 | NSRange selectedRange = [self textInputSelectedRange];
95 |
96 | if ([textField.delegate respondsToSelector:@selector(textField:shouldChangeCharactersInRange:replacementString:)]) {
97 | shouldInsertText = [textField.delegate textField:textField
98 | shouldChangeCharactersInRange:selectedRange
99 | replacementString:text];
100 | }
101 | }
102 |
103 | if (shouldInsertText == YES) {
104 | [self.textInput insertText:text];
105 | if (text.length <= 0) {//delete 键
106 | [self.textInput deleteBackward];
107 | }
108 | }
109 | }
110 |
111 | - (NSRange)textInputSelectedRange{
112 |
113 | UITextPosition *beginning = self.textInput.beginningOfDocument;
114 |
115 | UITextRange *selectedRange = self.textInput.selectedTextRange;
116 | UITextPosition *selectionStart = selectedRange.start;
117 | UITextPosition *selectionEnd = selectedRange.end;
118 |
119 | const NSInteger location = [self.textInput offsetFromPosition:beginning
120 | toPosition:selectionStart];
121 | const NSInteger length = [self.textInput offsetFromPosition:selectionStart
122 | toPosition:selectionEnd];
123 |
124 | return NSMakeRange(location, length);
125 | }
126 |
127 | - (void)updateButtonPosition{
128 |
129 | CGFloat leftPadding = CGRectGetMinX(self.frame);
130 | CGFloat rightPadding = CGRectGetMaxX(self.superview.frame) - CGRectGetMaxX(self.frame);
131 | CGFloat minimumClearance = CGRectGetWidth(self.frame) / 2 + 8;
132 |
133 | if (leftPadding >= minimumClearance && rightPadding >= minimumClearance) {
134 | self.position = YWKeyboardButtonPositionInner;
135 | } else if (leftPadding > rightPadding) {
136 | self.position = YWKeyboardButtonPositionLeft;
137 | } else {
138 | self.position = YWKeyboardButtonPositionRight;
139 | }
140 | }
141 |
142 | - (void)commonInit{
143 | self.exclusiveTouch = YES;
144 | _drawAmplification = YES;
145 | if (@available(iOS 13.0, *)) {
146 | _keyColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
147 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
148 | return [UIColor colorWithRed:80.0/255.f green:80.0/255.f blue:80.0/255.f alpha:1];
149 | }else{
150 | return [UIColor whiteColor];
151 | }
152 | }];
153 | _keyTextColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
154 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
155 | return [UIColor whiteColor];
156 | }else{
157 | return [UIColor blackColor];
158 | }
159 | }];
160 | _keyShadowColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
161 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
162 | return [UIColor colorWithRed:45.0 / 255.f green:45.0 / 255.f blue:45.0 / 255.f alpha:1];
163 | }else{
164 | return [UIColor colorWithRed:136 / 255.f green:138 / 255.f blue:142 / 255.f alpha:1];
165 | }
166 | }];
167 |
168 |
169 | } else {
170 | _keyColor = [UIColor whiteColor];
171 | _keyTextColor = [UIColor blackColor];
172 | _keyShadowColor = [UIColor colorWithRed:136 / 255.f green:138 / 255.f blue:142 / 255.f alpha:1];
173 | }
174 |
175 | _downGrayEffectColor = [UIColor colorWithRed:213/255.f green:214/255.f blue:216/255.f alpha:1];
176 | [self setTitleColor:_keyTextColor forState:UIControlStateNormal];
177 | [self setTitleColor:_keyTextColor forState:UIControlStateDisabled];
178 | [self setTitleColor:_keyTextColor forState:UIControlStateSelected];
179 |
180 | // UIControlEventTouchUpInside 先回触发 handleTouchDown ,才到 handleTouchUpInside
181 | [self addTarget:self action:@selector(handleTouchDown)
182 | forControlEvents:UIControlEventTouchDown];
183 | [self addTarget:self action:@selector(handleTouchUpInside)
184 | forControlEvents:UIControlEventTouchUpInside];
185 |
186 | }
187 |
188 |
189 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
190 | [super touchesEnded:touches withEvent:event];
191 | [self hideInputView];
192 | }
193 |
194 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
195 | [super touchesCancelled:touches withEvent:event];
196 | [self hideInputView];
197 | }
198 |
199 | - (void)layoutSubviews{
200 | [super layoutSubviews];
201 | [self updateButtonPosition];
202 | }
203 | - (void)drawRect:(CGRect)rect{
204 | CGContextRef context = UIGraphicsGetCurrentContext();
205 | UIColor *color = self.keyColor;
206 |
207 | UIColor *shadow = self.keyShadowColor;
208 | CGSize shadowOffset = CGSizeMake(0.1, 1.1);
209 | CGFloat shadowBlurRadius = 0;
210 |
211 | UIBezierPath *roundedRectanglePath =
212 | [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 1) cornerRadius:4.f];
213 | CGContextSaveGState(context);
214 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
215 | [color setFill];
216 | [roundedRectanglePath fill];
217 | CGContextRestoreGState(context);
218 | }
219 |
220 | - (void)setBgIconImage:(UIImage *)bgIconImage{
221 | _bgIconImage = bgIconImage;
222 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
223 | forState:UIControlStateNormal];
224 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
225 | forState:UIControlStateDisabled];
226 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
227 | forState:UIControlStateSelected];
228 | }
229 | - (void)setIconImage:(UIImage *)iconImage{
230 | _iconImage = iconImage;
231 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
232 | forState:UIControlStateNormal];
233 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
234 | forState:UIControlStateDisabled];
235 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
236 | forState:UIControlStateSelected];
237 | }
238 |
239 | - (void)setInput:(NSString *)input{
240 | _input = input;
241 | [self setTitle:input forState:UIControlStateNormal];
242 | [self setTitle:input forState:UIControlStateDisabled];
243 | [self setTitle:input forState:UIControlStateSelected];
244 | }
245 | - (void)setInputSelected:(NSString *)inputSelected{
246 | _inputSelected = inputSelected;
247 | [self setTitle:inputSelected forState:UIControlStateSelected];
248 | }
249 | - (void)setDelegate:(id)delegate{
250 | _delegate = delegate;
251 | _delegateHas.inTouchUpInside = delegate && [delegate respondsToSelector:@selector(interceptorTouchUpInside:)];
252 | _delegateHas.amplification = delegate && [delegate respondsToSelector:@selector(needDrawAmplification:)];
253 | _delegateHas.touchDownForState = delegate && [delegate respondsToSelector:@selector(handleTouchDownForState:)];
254 | }
255 | - (NSString *)getCurrentInputText{
256 | if (!_inputSelected) {
257 | return _input;
258 | }
259 | if (self.selected) {
260 | return _inputSelected;
261 | }
262 | return _input;
263 | }
264 | - (BOOL)isDrawAmplification{
265 | if (_delegateHas.amplification) {
266 | _drawAmplification = [_delegate needDrawAmplification:self];
267 | }
268 | //defalut is yes
269 | return _drawAmplification;
270 | }
271 | @end
272 |
273 | //MARK: ----- YWKeyboardDownButton ---------
274 |
275 | @interface YWKeyboardDownButton ()
276 | {
277 | struct {
278 | unsigned inTouchUpInside : 1;
279 | unsigned downGary : 1;
280 | } _delegateHas;
281 | struct {
282 | unsigned effectiveDigit : 1;
283 | } _dataSourceHas;
284 | }
285 | @end
286 |
287 | @implementation YWKeyboardDownButton
288 |
289 | - (id)initWithFrame:(CGRect)frame{
290 | self = [super initWithFrame:frame];
291 | if (self) {
292 | [self commonInit];
293 | }
294 | return self;
295 | }
296 |
297 | - (instancetype)initWithCoder:(NSCoder *)aDecoder{
298 | self = [super initWithCoder:aDecoder];
299 | if (self) {
300 | [self commonInit];
301 | }
302 | return self;
303 | }
304 | //手指按下按钮的事件
305 | - (void)handleTouchDown{
306 | [[UIDevice currentDevice] playInputClick];
307 | if ([self isNeedDownGrayEffect]) {
308 | [self setNeedsDisplay];
309 | }
310 | }
311 | - (void)handleTouchUpInside{
312 | BOOL isContinue = YES;
313 | if (_delegateHas.inTouchUpInside) {
314 | isContinue = [_delegate interceptorTouchUpInside:self];
315 | }
316 | if (!isContinue) return;
317 |
318 | [self insertText:self.input];
319 |
320 | }
321 | - (void)insertText:(NSString *)text{
322 | BOOL shouldInsertText = YES;
323 |
324 | if ([self.textInput isKindOfClass:[UITextView class]]) {
325 | // Call UITextViewDelegate methods if necessary
326 | UITextView *textView = (UITextView *)self.textInput;
327 | NSRange selectedRange = textView.selectedRange;
328 |
329 | if ([textView.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)]) {
330 | shouldInsertText = [textView.delegate textView:textView
331 | shouldChangeTextInRange:selectedRange
332 | replacementText:text];
333 | }
334 | } else if ([self.textInput isKindOfClass:[UITextField class]]) {
335 | // Call UITextFieldDelgate methods if necessary
336 | UITextField *textField = (UITextField *)self.textInput;
337 | NSRange selectedRange = [self textInputSelectedRange];
338 |
339 | if ([textField.delegate respondsToSelector:@selector(textField:shouldChangeCharactersInRange:replacementString:)]) {
340 | shouldInsertText = [textField.delegate textField:textField
341 | shouldChangeCharactersInRange:selectedRange
342 | replacementString:text];
343 | }
344 | NSInteger effectiveDigit = [self isEffectiveDigit];
345 | if (effectiveDigit != 0) {
346 | shouldInsertText = [self canInput:textField
347 | inRange:selectedRange
348 | replacementString:text
349 | canDigits:effectiveDigit];
350 | if ([textField.text isEqual:@"0"] && !shouldInsertText) {
351 | [self.textInput deleteBackward];
352 | shouldInsertText = YES;
353 | }
354 | }
355 | }
356 | if (shouldInsertText == YES) {
357 | [self.textInput insertText:text];
358 | if (text.length <= 0) {//delete 键
359 | [self.textInput deleteBackward];
360 | }
361 | }
362 | }
363 |
364 | - (NSRange)textInputSelectedRange{
365 |
366 | UITextPosition *beginning = self.textInput.beginningOfDocument;
367 |
368 | UITextRange *selectedRange = self.textInput.selectedTextRange;
369 | UITextPosition *selectionStart = selectedRange.start;
370 | UITextPosition *selectionEnd = selectedRange.end;
371 |
372 | const NSInteger location = [self.textInput offsetFromPosition:beginning
373 | toPosition:selectionStart];
374 | const NSInteger length = [self.textInput offsetFromPosition:selectionStart
375 | toPosition:selectionEnd];
376 |
377 | return NSMakeRange(location, length);
378 | }
379 |
380 | /// 判断是数字有效否可以继续输入数字
381 | /// @param textField 输入框
382 | /// @param range 选择范围
383 | /// @param string 单个数字
384 | - (BOOL)canInput:(UITextField *)textField
385 | inRange:(NSRange)range
386 | replacementString:(NSString *)string
387 | canDigits:(NSInteger)digits{
388 | NSString *toString = [textField.text stringByReplacingCharactersInRange:range withString:string];
389 | if (toString.length > 0) {
390 | // 保留规则: 小数点后2位
391 | // NSString *stringRegex = @"^\\-?([1-9]\\d*|0)(\\.\\d{0,2})?$";
392 | NSString *stringRegex = [NSString stringWithFormat:@"^\\-?([1-9]\\d*|0)(\\.\\d{0,%zi})?$",digits];
393 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", stringRegex];
394 | BOOL flag = [predicate evaluateWithObject:toString];
395 | if (!flag) {
396 | return NO;
397 | }
398 | }
399 | return YES;
400 | }
401 |
402 | - (void)commonInit{
403 | self.exclusiveTouch = YES;
404 | _drawShadow = YES;
405 | if (@available(iOS 13.0, *)) {
406 | _keyColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
407 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
408 | return [UIColor colorWithRed:80.0/255.f green:80.0/255.f blue:80.0/255.f alpha:1];
409 | }else{
410 | return [UIColor whiteColor];
411 | }
412 | }];
413 | _keyTextColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
414 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
415 | return [UIColor whiteColor];
416 | }else{
417 | return [UIColor blackColor];
418 | }
419 | }];
420 | _keyShadowColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
421 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
422 | return [UIColor colorWithRed:45.0 / 255.f green:45.0 / 255.f blue:45.0 / 255.f alpha:1];
423 | }else{
424 | return [UIColor colorWithRed:136 / 255.f green:138 / 255.f blue:142 / 255.f alpha:1];
425 | }
426 | }];
427 |
428 |
429 | } else {
430 | _keyColor = [UIColor whiteColor];
431 | _keyTextColor = [UIColor blackColor];
432 | _keyShadowColor = [UIColor colorWithRed:136 / 255.f green:138 / 255.f blue:142 / 255.f alpha:1];
433 | }
434 |
435 | _downGrayEffectColor = [UIColor colorWithRed:213/255.f green:214/255.f blue:216/255.f alpha:1];
436 | [self setTitleColor:_keyTextColor forState:UIControlStateNormal];
437 | [self setTitleColor:_keyTextColor forState:UIControlStateDisabled];
438 | [self setTitleColor:_keyTextColor forState:UIControlStateSelected];
439 |
440 | // UIControlEventTouchUpInside 先回触发 handleTouchDown ,才到 handleTouchUpInside
441 | [self addTarget:self action:@selector(handleTouchDown)
442 | forControlEvents:UIControlEventTouchDown];
443 | [self addTarget:self action:@selector(handleTouchUpInside)
444 | forControlEvents:UIControlEventTouchUpInside];
445 |
446 | }
447 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
448 | [super touchesEnded:touches withEvent:event];
449 | [self setNeedsDisplay];
450 | }
451 |
452 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
453 | [super touchesCancelled:touches withEvent:event];
454 | [self setNeedsDisplay];
455 | }
456 |
457 | - (void)drawRect:(CGRect)rect{
458 | if (_specificNoDown) {
459 | [super drawRect:rect];
460 | return;
461 | }
462 | if (_drawShadow) {//绘制按钮的样式
463 | //进一步判断是否需要绘制点击效果
464 | [self judgeGrayEffectOfDrawShadow];
465 | }else{
466 | [self judgeGrayEffectOfNoDrawShadow:rect];
467 | }
468 | }
469 | - (void)judgeGrayEffectOfDrawShadow{
470 | if ([self isNeedDownGrayEffect]) {//需要绘制点击效果
471 | if (self.isHighlighted) {//当前处于按下状态
472 | [self drawDownGrayEffectOfDrawShadow];
473 | return;
474 | }
475 | //松手指,松开状态:还原原来的效果
476 | [self drawBorderStyle];
477 | return;
478 | }
479 | //不需要点击效果
480 | [self drawBorderStyle];
481 | }
482 | - (void)judgeGrayEffectOfNoDrawShadow:(CGRect)rect{
483 | if ([self isNeedDownGrayEffect]) {//需要绘制点击效果
484 | if (self.isHighlighted) {//当前处于按下状态
485 | [self drawDownGrayEffectOfNoDrawShadow];
486 | return;
487 | }
488 | //松手指,松开状态:还原原来的效果
489 | [self drawDefalutOfNoDrawShadow];
490 | return;
491 | }
492 | //不需要点击效果
493 | [super drawRect:rect];
494 | }
495 |
496 | - (void)drawBorderStyle{
497 | CGContextRef context = UIGraphicsGetCurrentContext();
498 | UIColor *color = self.keyColor;
499 |
500 | UIColor *shadow = self.keyShadowColor;
501 | CGSize shadowOffset = CGSizeMake(0.1, 1.1);
502 | CGFloat shadowBlurRadius = 0;
503 |
504 | UIBezierPath *roundedRectanglePath =
505 | [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0,
506 | 0,
507 | self.frame.size.width,
508 | self.frame.size.height - 1)
509 | cornerRadius:4.f];
510 | CGContextSaveGState(context);
511 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
512 | [color setFill];
513 | [roundedRectanglePath fill];
514 | CGContextRestoreGState(context);
515 | }
516 | - (void)drawDownGrayEffectOfDrawShadow{
517 | CGContextRef context = UIGraphicsGetCurrentContext();
518 | UIColor *color = self.downGrayEffectColor;
519 |
520 | UIColor *shadow = self.keyShadowColor;
521 | CGSize shadowOffset = CGSizeMake(0.1, 1.1);
522 | CGFloat shadowBlurRadius = 0;
523 |
524 | UIBezierPath *roundedRectanglePath =
525 | [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0,
526 | 0,
527 | self.frame.size.width,
528 | self.frame.size.height - 1)
529 | cornerRadius:4.f];
530 | CGContextSaveGState(context);
531 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
532 | [color setFill];
533 | [roundedRectanglePath fill];
534 | CGContextRestoreGState(context);
535 | }
536 | //MARK: --- 按下效果相关 ----
537 |
538 | /// 默认【原始效果】
539 | - (void)drawDefalutOfNoDrawShadow{
540 | CGContextRef context = UIGraphicsGetCurrentContext();
541 | UIColor *color = self.keyColor;
542 | UIBezierPath *roundedRectanglePath = [UIBezierPath bezierPathWithRect:
543 | CGRectMake(0,
544 | 0,
545 | self.frame.size.width,
546 | self.frame.size.height)];
547 | CGContextSaveGState(context);
548 | [color setFill];
549 | [roundedRectanglePath fill];
550 | CGContextRestoreGState(context);
551 | }
552 | /// 按下的效果设置
553 | - (void)drawDownGrayEffectOfNoDrawShadow{
554 | CGContextRef context = UIGraphicsGetCurrentContext();
555 | UIColor *color = self.downGrayEffectColor;
556 | UIBezierPath *roundedRectanglePath = [UIBezierPath bezierPathWithRect:
557 | CGRectMake(0,
558 | 0,
559 | self.frame.size.width,
560 | self.frame.size.height)];
561 | CGContextSaveGState(context);
562 | [color setFill];
563 | [roundedRectanglePath fill];
564 | CGContextRestoreGState(context);
565 | }
566 |
567 |
568 |
569 |
570 | - (void)setBgIconImage:(UIImage *)bgIconImage{
571 | _bgIconImage = bgIconImage;
572 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
573 | forState:UIControlStateNormal];
574 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
575 | forState:UIControlStateDisabled];
576 | [self setBackgroundImage:[bgIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
577 | forState:UIControlStateSelected];
578 | }
579 | - (void)setIconImage:(UIImage *)iconImage{
580 | _iconImage = iconImage;
581 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
582 | forState:UIControlStateNormal];
583 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
584 | forState:UIControlStateDisabled];
585 | [self setImage:[iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
586 | forState:UIControlStateSelected];
587 | }
588 |
589 | - (void)setInput:(NSString *)input{
590 | _input = input;
591 | [self setTitle:input forState:UIControlStateNormal];
592 | [self setTitle:input forState:UIControlStateDisabled];
593 | [self setTitle:input forState:UIControlStateSelected];
594 | }
595 | - (void)setDelegate:(id)delegate{
596 | _delegate = delegate;
597 | _delegateHas.inTouchUpInside = delegate && [delegate respondsToSelector:
598 | @selector(interceptorTouchUpInside:)];
599 | _delegateHas.downGary = delegate && [delegate respondsToSelector:
600 | @selector(needDownGrayEffect:)];
601 | }
602 | - (void)setDataSource:(id)dataSource{
603 | _dataSource = dataSource;
604 | _dataSourceHas.effectiveDigit = dataSource && [dataSource respondsToSelector:
605 | @selector(isEffectiveDigitForInput:)];
606 | }
607 | - (BOOL)isNeedDownGrayEffect{
608 | if (_delegateHas.downGary) {//优先级别needDownGrayEffect>_downGray
609 | _downGray = [_delegate needDownGrayEffect:self];
610 | }
611 | return _downGray;
612 | }
613 | - (NSInteger)isEffectiveDigit{
614 | if (_dataSourceHas.effectiveDigit) {
615 | return [_dataSource isEffectiveDigitForInput:self];
616 | }
617 | return 0;
618 | }
619 | @end
620 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/KeyboardButton/YWTipUpView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWTipUpView.h
3 | // TextKeyBoard
4 | //
5 | // Created by Mr.Yao on 2020/2/27.
6 | // Copyright © 2020 Mr.Yao. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 |
14 | @class YWKeyboardButton;
15 |
16 | @interface YWTipUpView : UIView
17 |
18 | @property (nonatomic, readonly) NSInteger selectedInputIndex;
19 |
20 | - (instancetype)initWithKeyboardButton:(YWKeyboardButton *)button;
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/KeyboardButton/YWTipUpView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWTipUpView.m
3 | // TextKeyBoard
4 | //
5 | // Created by Mr.Yao on 2020/2/27.
6 | // Copyright © 2020 Mr.Yao. All rights reserved.
7 | //
8 |
9 | #import "YWTipUpView.h"
10 | #import "YWKeyboardButton.h"
11 | #import
12 |
13 | @interface YWTipUpView ()
14 |
15 | @property (nonatomic, weak) YWKeyboardButton *button;
16 | @property (nonatomic, strong) NSMutableArray *inputOptionRects;
17 | @property (nonatomic, assign) NSInteger selectedInputIndex;
18 |
19 | @end
20 |
21 |
22 | @implementation YWTipUpView
23 |
24 | - (instancetype)initWithKeyboardButton:(YWKeyboardButton *)button{
25 | CGRect frame = [UIScreen mainScreen].bounds;
26 | self = [super initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
27 | if (self) {
28 | _button = button;
29 | self.backgroundColor = [UIColor clearColor];
30 | self.userInteractionEnabled = NO;
31 | }
32 | return self;
33 | }
34 | - (void)drawRect:(CGRect)rect{
35 | if (_button.drawAmplification) {
36 | [self drawInputView:rect];
37 | }else{
38 | [super drawRect:rect];
39 | }
40 | }
41 | - (UIBezierPath *)inputViewPath{
42 | CGRect keyRect = [self convertRect:self.button.frame fromView:self.button.superview];
43 |
44 | UIEdgeInsets insets = UIEdgeInsetsMake(7, 13, 7, 13);
45 | CGFloat upperWidth = CGRectGetWidth(_button.frame) + insets.left + insets.right;
46 | CGFloat lowerWidth = CGRectGetWidth(_button.frame);
47 | CGFloat majorRadius = 10.f;
48 | CGFloat minorRadius = 4.f;
49 |
50 | TurtleBezierPath *path = [TurtleBezierPath new];
51 | [path home];
52 | path.lineWidth = 0;
53 | path.lineCapStyle = kCGLineCapRound;
54 |
55 | switch (self.button.position) {
56 | case YWKeyboardButtonPositionInner:
57 | {
58 | [path rightArc:majorRadius turn:90]; // #1
59 | [path forward:upperWidth - 2 * majorRadius]; // #2 top
60 | [path rightArc:majorRadius turn:90]; // #3
61 | [path forward:CGRectGetHeight(keyRect) - 2 * majorRadius + insets.top + insets.bottom]; // #4 right big
62 | [path rightArc:majorRadius turn:48]; // #5
63 | [path forward:8.5f];
64 | [path leftArc:majorRadius turn:48]; // #6
65 | [path forward:CGRectGetHeight(keyRect) - 8.5f + 1];
66 | [path rightArc:minorRadius turn:90];
67 | [path forward:lowerWidth - 2 * minorRadius]; // lowerWidth - 2 * minorRadius + 0.5f
68 | [path rightArc:minorRadius turn:90];
69 | [path forward:CGRectGetHeight(keyRect) - 2 * minorRadius];
70 | [path leftArc:majorRadius turn:48];
71 | [path forward:8.5f];
72 | [path rightArc:majorRadius turn:48];
73 |
74 | CGFloat offsetX = 0, offsetY = 0;
75 | CGRect pathBoundingBox = path.bounds;
76 |
77 | offsetX = CGRectGetMidX(keyRect) - CGRectGetMidX(path.bounds);
78 | offsetY = CGRectGetMaxY(keyRect) - CGRectGetHeight(pathBoundingBox) + 10;
79 |
80 | [path applyTransform:CGAffineTransformMakeTranslation(offsetX, offsetY)];
81 | }
82 | break;
83 |
84 | case YWKeyboardButtonPositionLeft:
85 | {
86 | [path rightArc:majorRadius turn:90]; // #1
87 | [path forward:upperWidth - 2 * majorRadius]; // #2 top
88 | [path rightArc:majorRadius turn:90]; // #3
89 | [path forward:CGRectGetHeight(keyRect) - 2 * majorRadius + insets.top + insets.bottom]; // #4 right big
90 | [path rightArc:majorRadius turn:45]; // #5
91 | [path forward:28]; // 6
92 | [path leftArc:majorRadius turn:45]; // #7
93 | [path forward:CGRectGetHeight(keyRect) - 26 + (insets.left + insets.right) / 4]; // #8
94 | [path rightArc:minorRadius turn:90]; // 9
95 | [path forward:path.currentPoint.x - minorRadius]; // 10
96 | [path rightArc:minorRadius turn:90]; // 11
97 |
98 |
99 | CGFloat offsetX = 0, offsetY = 0;
100 | CGRect pathBoundingBox = path.bounds;
101 |
102 | offsetX = CGRectGetMaxX(keyRect) - CGRectGetWidth(path.bounds);
103 | offsetY = CGRectGetMaxY(keyRect) - CGRectGetHeight(pathBoundingBox) - CGRectGetMinY(path.bounds);
104 |
105 | [path applyTransform:CGAffineTransformTranslate(CGAffineTransformMakeScale(-1, 1), -offsetX - CGRectGetWidth(path.bounds), offsetY)];
106 | }
107 | break;
108 |
109 | case YWKeyboardButtonPositionRight:
110 | {
111 | [path rightArc:majorRadius turn:90]; // #1
112 | [path forward:upperWidth - 2 * majorRadius]; // #2 top
113 | [path rightArc:majorRadius turn:90]; // #3
114 | [path forward:CGRectGetHeight(keyRect) - 2 * majorRadius + insets.top + insets.bottom]; // #4 right big
115 | [path rightArc:majorRadius turn:45]; // #5
116 | [path forward:28]; // 6
117 | [path leftArc:majorRadius turn:45]; // #7
118 | [path forward:CGRectGetHeight(keyRect) - 26 + (insets.left + insets.right) / 4]; // #8
119 | [path rightArc:minorRadius turn:90]; // 9
120 | [path forward:path.currentPoint.x - minorRadius]; // 10
121 | [path rightArc:minorRadius turn:90]; // 11
122 |
123 | CGFloat offsetX = 0, offsetY = 0;
124 | CGRect pathBoundingBox = path.bounds;
125 |
126 | offsetX = CGRectGetMinX(keyRect);
127 | offsetY = CGRectGetMaxY(keyRect) - CGRectGetHeight(pathBoundingBox) - CGRectGetMinY(path.bounds);
128 |
129 | [path applyTransform:CGAffineTransformMakeTranslation(offsetX, offsetY)];
130 | }
131 | break;
132 |
133 | default:
134 | break;
135 | }
136 |
137 | return path;
138 | }
139 |
140 | - (void)drawInputView:(CGRect)rect{
141 | {
142 | // Generate the overlay
143 | UIBezierPath *bezierPath = [self inputViewPath];
144 | NSString *input = [self.button getCurrentInputText];
145 | NSString *inputString = input ? input : @"";
146 |
147 | // Position the overlay
148 | CGRect keyRect = [self convertRect:self.button.frame fromView:self.button.superview];
149 |
150 | CGContextRef context = UIGraphicsGetCurrentContext();
151 |
152 | // Overlay path & shadow
153 | {
154 | //// Shadow Declarations
155 | UIColor* shadow = [[UIColor blackColor] colorWithAlphaComponent: 0.5];
156 | CGSize shadowOffset = CGSizeMake(0, 0.5);
157 | CGFloat shadowBlurRadius = 2;
158 |
159 | //// Rounded Rectangle Drawing
160 | CGContextSaveGState(context);
161 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
162 | [self.button.keyColor setFill];
163 | [bezierPath fill];
164 | CGContextRestoreGState(context);
165 | }
166 |
167 | // Draw the key shadow sliver
168 | {
169 | //// Color Declarations
170 | UIColor *color = self.button.keyColor;
171 |
172 | //// Shadow Declarations
173 | UIColor *shadow = self.button.keyShadowColor;
174 | CGSize shadowOffset = CGSizeMake(0.1, 1.1);
175 | CGFloat shadowBlurRadius = 0;
176 |
177 | //// Rounded Rectangle Drawing
178 | UIBezierPath *roundedRectanglePath =
179 | [UIBezierPath bezierPathWithRoundedRect:CGRectMake(keyRect.origin.x, keyRect.origin.y, keyRect.size.width, keyRect.size.height - 1) cornerRadius:4];
180 | CGContextSaveGState(context);
181 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
182 | [color setFill];
183 | [roundedRectanglePath fill];
184 |
185 | CGContextRestoreGState(context);
186 | }
187 |
188 | // Text drawing
189 | {
190 | UIColor *stringColor = self.button.keyTextColor;
191 |
192 | CGRect stringRect = bezierPath.bounds;
193 |
194 | NSMutableParagraphStyle *p = [NSMutableParagraphStyle new];
195 | p.alignment = NSTextAlignmentCenter;
196 |
197 | NSAttributedString *attributedString = [[NSAttributedString alloc]
198 | initWithString:inputString
199 | attributes:
200 | @{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:44], NSForegroundColorAttributeName : stringColor, NSParagraphStyleAttributeName : p}];
201 | [attributedString drawInRect:stringRect];
202 | }
203 | }
204 | }
205 |
206 | @end
207 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/LicensePlate/YWLicensePlateView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWLicensePlateView.h
3 | // NMChangJieCloud
4 | //
5 | // Created by yaowei on 2018/12/14.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWLicensePlateView : UIInputView
13 |
14 | @property (nonatomic, weak, readonly) id textInput;
15 |
16 | /// 英文中文[车牌省份编码]切换键盘
17 | /// @param textInput 输入框
18 | + (instancetype)getEnglishOrProvinceLicensePlate:(id)textInput;
19 |
20 | /// 中文[车牌省份编码]或英文字母换键盘
21 | /// @param textInput 输入框
22 | + (instancetype)getProvinceOrEnglishLicensePlate:(id)textInput;
23 |
24 |
25 | /// 手动切换至英文键盘
26 | - (void)showEnglishNumView;
27 |
28 | /// 手动切换至省份键盘
29 | - (void)showProvinceView;
30 | @end
31 |
32 | NS_ASSUME_NONNULL_END
33 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/LicensePlate/YWLicensePlateView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWLicensePlateView.m
3 | // NMChangJieCloud
4 | //
5 | // Created by yaowei on 2018/12/14.
6 | //
7 |
8 | #import "YWLicensePlateView.h"
9 | #import
10 |
11 |
12 |
13 |
14 |
15 |
16 | @interface YWLicensePlateView ()
17 |
18 | @property (nonatomic, weak, readwrite) id textInput;
19 |
20 | @property (nonatomic, strong ) NSMutableArray *proviceCodeList;
21 |
22 | @property (nonatomic, strong ) NSMutableArray *numPinList;
23 |
24 | @property (nonatomic, weak ) UIView *proviceCodeView;
25 |
26 | @property (nonatomic, weak ) UIView *numPinView;
27 |
28 | @property (nonatomic, strong ) UIColor *deleteColor;
29 |
30 | @property (nonatomic, strong, nullable) NSBundle *thisBundle;
31 |
32 | @property (nonatomic, strong, nullable) NSTimer *timer;
33 |
34 |
35 | @end
36 |
37 |
38 | @implementation YWLicensePlateView
39 |
40 | + (instancetype)getEnglishOrProvinceLicensePlate:(id)textInput{
41 | return [[YWLicensePlateView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput fitstType:YES];
42 | }
43 | + (instancetype)getProvinceOrEnglishLicensePlate:(id)textInput{
44 | return [[YWLicensePlateView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput fitstType:NO];
45 | }
46 | - (instancetype)initWithFrame:(CGRect)frame
47 | inputViewStyle:(UIInputViewStyle)inputViewStyle
48 | textInput:(id)textInput
49 | fitstType:(BOOL)number{
50 |
51 | self = [super initWithFrame:frame inputViewStyle:inputViewStyle];
52 | if (self) {
53 | _textInput = textInput;
54 | [self createViewNumPinView];
55 | [self createViewProviceCodeView];
56 | if (number) {
57 | [self showNumPinView];
58 | }else{
59 | [self showProviceCodeView];
60 | }
61 | }
62 | return self;
63 | }
64 | - (void)showEnglishNumView{
65 | [self showNumPinView];
66 | [self.timer invalidate];
67 | self.timer = nil;
68 | }
69 | - (void)showProvinceView{
70 | [self showProviceCodeView];
71 | [self.timer invalidate];
72 | self.timer = nil;
73 | }
74 | //MARK: -------- YWKeyboardButtonDelegate -----------
75 | - (BOOL)interceptorTouchUpInside:(YWKeyboardButton *)button{
76 | if (button.tag == 900) {//ABC
77 | [self showNumPinView];
78 | [self.timer invalidate];
79 | self.timer = nil;
80 | return NO;
81 | }
82 | if (button.tag == 901){//中
83 | [self showProviceCodeView];
84 | [self.timer invalidate];
85 | self.timer = nil;
86 | return NO;
87 | }
88 | return YES;
89 | }
90 | - (BOOL)needDrawAmplification:(YWKeyboardButton *)button{
91 | if (button.tag == 900) {//ABC
92 | return NO;
93 | }
94 | if (button.tag == 901){//中
95 | return NO;
96 | }
97 | if (button.tag == 902) {//delegate
98 | return NO;
99 | }
100 | return YES;
101 | }
102 |
103 |
104 |
105 |
106 |
107 | //MARK: -------- UI ----------------
108 |
109 | - (void)createViewProviceCodeView{
110 |
111 | NSInteger lineItem = 9;
112 | CGFloat leftX = 5;
113 | CGFloat space = 6;
114 | NSInteger i = 0;
115 | CGFloat top = 5;
116 | CGFloat width = ([UIScreen mainScreen].bounds.size.width - (lineItem - 1) * space - leftX * 2)/lineItem;
117 | CGFloat height = 1.34375 * width;
118 |
119 | CGFloat viewHeight = 5 * (top * 2 + height);
120 | CGFloat both_x = YW_KEYBOARD_TABBARBOTTOM;
121 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight + both_x);
122 |
123 | [self addSubview:({
124 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight)];
125 | _proviceCodeView = v;
126 | v;
127 | })];
128 |
129 | //针对小屏幕,处理字体
130 | CGSize size4 = CGSizeMake(320,568);
131 | CGSize mainSize = [UIScreen mainScreen].bounds.size;
132 | UIFont *font = [UIFont systemFontOfSize:14];
133 | if (size4.width == mainSize.width && size4.height == mainSize.height) {//4.0
134 | font = [UIFont systemFontOfSize:12];
135 | }
136 | CGFloat fixedHeight = height + top + top;
137 |
138 | for (NSString *kText in self.proviceCodeList) {
139 | NSInteger index = i % lineItem;
140 | NSInteger page = i / lineItem;
141 | YWKeyboardButton *btn = [YWKeyboardButton buttonWithType:UIButtonTypeCustom];
142 | CGFloat currentX = index * (width + space) + leftX;
143 | // if (i >= 37) {
144 | // currentX = index * (width + space) + leftX + width;
145 | // }
146 | if (i == 36){//abc
147 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
148 | btn.tag = 900;
149 | btn.keyColor = self.deleteColor;
150 | btn.delegate = self;
151 | btn.titleLabel.font = font;
152 | }else if (i == 43){//delete
153 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width+width+space, height);
154 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
155 | btn.keyColor = self.deleteColor;
156 | btn.tag = 902;
157 | btn.delegate = self;
158 | [self addLongGesAction:btn];
159 | }else{
160 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
161 | }
162 | btn.input = kText;
163 | btn.textInput = _textInput;
164 | [_proviceCodeView addSubview:btn];
165 | i ++;
166 | }
167 | }
168 |
169 | - (void)createViewNumPinView{
170 |
171 | NSInteger lineItem = 10;
172 | CGFloat leftX = 5;
173 | CGFloat space = 6;
174 | NSInteger i = 0;
175 | CGFloat top = 5;
176 | CGFloat width = ([UIScreen mainScreen].bounds.size.width - (lineItem - 1) * space - leftX * 2)/lineItem;
177 | CGFloat height = 1.34375 * width;
178 |
179 | CGFloat viewHeight = 4 * (top * 2 + height);
180 | CGFloat both_x = YW_KEYBOARD_TABBARBOTTOM;
181 |
182 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight + both_x);
183 |
184 | [self addSubview:({
185 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight)];
186 | _numPinView = v;
187 | v;
188 | })];
189 |
190 | CGFloat fixedHeight = height + top + top;
191 |
192 | for (NSString *kText in self.numPinList) {
193 | NSInteger index = i % lineItem;
194 | NSInteger page = i / lineItem;
195 | YWKeyboardButton *btn = [YWKeyboardButton buttonWithType:UIButtonTypeCustom];
196 | if (i < 20) {
197 | CGFloat currentX = index * (width + space) + leftX;
198 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
199 | }else if (i < 29){
200 | CGFloat currentX = index * (width + space) + (width/2 + 6);
201 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
202 | }else if (i < 30){//切换
203 | CGFloat currentLeft = 1 * (width + space) + (width/2 + 6);//z的左距离
204 | CGFloat currentW = currentLeft - 5 - 13;
205 | CGFloat currentX = 0 * (width + space) + leftX;
206 | btn.frame = CGRectMake(currentX, top + fixedHeight * 3, currentW, height);
207 |
208 | btn.tag = 901;
209 | btn.keyColor = self.deleteColor;
210 | btn.delegate = self;
211 |
212 | }else if(i > 36){
213 | CGFloat currentZLeft = 1 * (width + space) + (width/2 + 6);//z的左距离
214 | CGFloat currentW = currentZLeft - 5 - 13;
215 | CGFloat currentLeft = 8 * (width + space) + (width/2 + 6) + 9;
216 | btn.frame = CGRectMake(currentLeft, top + fixedHeight * page, currentW, height);
217 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
218 | btn.tag = 902;
219 | btn.keyColor = self.deleteColor;
220 | btn.delegate = self;
221 | [self addLongGesAction:btn];
222 |
223 | }else{
224 | CGFloat currentLeft = 1 * (width + space) + (width/2 + 6);
225 | CGFloat currentX = index * (width + space) + currentLeft;
226 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
227 | }
228 | btn.input = kText;
229 | btn.textInput = _textInput;
230 | [_numPinView addSubview:btn];
231 | i ++;
232 | }
233 | }
234 |
235 | - (void)showProviceCodeView{
236 | _numPinView.hidden = YES;
237 | _proviceCodeView.hidden = NO;
238 | CGRect rect = self.frame;
239 | rect.size.height = CGRectGetHeight(_proviceCodeView.frame)+YW_KEYBOARD_TABBARBOTTOM;
240 | NSArray * constraints = self.constraints;
241 | BOOL isModity = NO;
242 | for (NSLayoutConstraint *constraint in constraints) {
243 | if(constraint.firstAttribute == NSLayoutAttributeHeight){
244 | constraint.constant = rect.size.height;
245 | isModity = YES;
246 | break;
247 | }
248 | }
249 | if(!isModity){
250 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, rect.size.height);
251 | }
252 | }
253 |
254 | - (void)showNumPinView{
255 | _proviceCodeView.hidden = YES;
256 | _numPinView.hidden = NO;
257 | CGRect rect = self.frame;
258 | rect.size.height = CGRectGetHeight(_numPinView.frame)+YW_KEYBOARD_TABBARBOTTOM;
259 | NSArray * constraints = self.constraints;
260 | BOOL isModity = NO;
261 | for (NSLayoutConstraint *constraint in constraints) {
262 | if(constraint.firstAttribute == NSLayoutAttributeHeight){
263 | constraint.constant = rect.size.height;
264 | isModity = YES;
265 | break;
266 | }
267 | }
268 | if(!isModity){
269 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, rect.size.height);
270 | }
271 | }
272 | //MARK: --- 长按 delete ----
273 | - (void)addLongGesAction:(YWKeyboardButton *) btn{
274 | UILongPressGestureRecognizer *ges = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(deleteWithLognGes:)];
275 | [btn addGestureRecognizer:ges];
276 | }
277 |
278 | - (void)deleteWithLognGes:(UILongPressGestureRecognizer *)sender{
279 | if (sender.state == UIGestureRecognizerStateBegan) {
280 | [self.timer invalidate];
281 | self.timer = nil;
282 | self.timer = [NSTimer timerWithTimeInterval:0.1
283 | target:self
284 | selector:@selector(deleteAction)
285 | userInfo:nil
286 | repeats:YES];
287 | [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
288 | }else if (sender.state == UIGestureRecognizerStateEnded){
289 | [self.timer invalidate];
290 | self.timer = nil;
291 | }
292 | }
293 | - (void)deleteAction{
294 | [self.textInput deleteBackward];
295 | }
296 | //MARK: --- load YWKeyboardKit Bundle image ----
297 | - (UIImage *)getImageOnBundleWithImage:(NSString *)imageName{
298 | return [self getImageOnBundle:imageName ofType:@"png"];
299 | }
300 | - (UIImage *)getImageOnBundle:(NSString *)imageName
301 | ofType:(NSString *)type{
302 |
303 | return [UIImage imageNamed:imageName
304 | inBundle:self.thisBundle compatibleWithTraitCollection:nil];
305 |
306 | }
307 |
308 | //MARK: --- getter && setter
309 | - (NSBundle *)thisBundle{
310 | if (!_thisBundle) {
311 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
312 |
313 | NSURL *url = [bundle URLForResource:@"YWKeyboardKit"
314 | withExtension:@"bundle"];
315 |
316 | _thisBundle = [NSBundle bundleWithURL:url];
317 | }
318 | return _thisBundle;
319 | }
320 | - (NSMutableArray *)proviceCodeList{
321 | if (!_proviceCodeList) {
322 | // _proviceCodeList = [NSMutableArray arrayWithArray:
323 | // @[@"京",@"津",@"渝",@"沪",@"冀",@"晋",@"辽",@"吉",@"黑",@"苏",
324 | // @"浙",@"皖",@"闽",@"赣",@"鲁",@"豫",@"鄂",@"湘",@"粤",@"琼",
325 | // @"川",@"贵",@"云",@"陕",@"甘",@"青",@"蒙",@"桂",@"宁",@"新",
326 | // @"ABC", @"藏",@"使",@"领",@"警",@"学",@"港",@"澳",@"挂", @""
327 | // ]];
328 | _proviceCodeList = [NSMutableArray arrayWithArray:
329 | @[@"京",@"津",@"渝",@"沪",@"冀",@"晋",@"辽",@"吉",@"黑",
330 | @"苏",@"浙",@"皖",@"闽",@"赣",@"鲁",@"豫",@"鄂",@"湘",
331 | @"粤",@"琼",@"川",@"贵",@"云",@"陕",@"甘",@"青",@"蒙",
332 | @"桂",@"宁",@"新",@"藏",@"警",@"学",@"港",@"澳",@"使",
333 | @"ABC",@"领",@"挂",@"试",@"应",@"急",@"临",@""
334 | ]];
335 | }
336 | return _proviceCodeList;
337 | }
338 | - (NSMutableArray *)numPinList{
339 | if (!_numPinList) {
340 | _numPinList = [NSMutableArray arrayWithArray:@[
341 | @"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"0",
342 | @"Q",@"W",@"E",@"R",@"T",@"Y",@"U",@"I",@"O",@"P",
343 | @"A",@"S",@"D",@"F",@"G",@"H",@"J",@"K",@"L",
344 | @"中",@"Z",@"X",@"C",@"V",@"B",@"N",@"M",@""
345 | ]];
346 | }
347 | return _numPinList;
348 | }
349 | - (UIColor *)deleteColor{
350 | if (!_deleteColor) {
351 | if (@available(iOS 13.0, *)) {
352 | _deleteColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
353 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
354 | return [UIColor colorWithRed:46.0/255.f green:46.0/255.f blue:46.0/255.f alpha:1];
355 | }else{
356 | return [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
357 | }
358 | }];
359 | } else {
360 | _deleteColor = [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
361 | }
362 | }
363 | return _deleteColor;
364 | }
365 |
366 |
367 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
368 | YWKeyboardButton *btn = [_proviceCodeView viewWithTag:902];
369 | YWKeyboardButton *btn1 = [_numPinView viewWithTag:902];
370 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
371 | btn1.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
372 | }
373 | - (void)layoutSubviews{
374 | [super layoutSubviews];
375 | }
376 | @end
377 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/LicensePlate/YWProvinceLicensePlatePrefixView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWProvinceLicensePlatePrefixView.h
3 | // NMChangJieCloud
4 | //
5 | // Created by yaowei on 2018/12/14.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWProvinceLicensePlatePrefixView : UIInputView
13 |
14 | @property (nonatomic, weak,readonly) id textInput;
15 | /// 只有省份的键盘
16 | /// @param textInput 输入框
17 | + (instancetype)getDefalutProvinceKeyBoardView:(id)textInput;
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/LicensePlate/YWProvinceLicensePlatePrefixView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWProvinceLicensePlatePrefixView.m
3 | // NMChangJieCloud
4 | //
5 | // Created by yaowei on 2018/12/14.
6 | //
7 |
8 | #import "YWProvinceLicensePlatePrefixView.h"
9 | #import
10 |
11 | @interface YWProvinceLicensePlatePrefixView ()
12 |
13 | @property (nonatomic, weak, readwrite) id textInput;
14 |
15 | @property (nonatomic, strong ) NSMutableArray *proviceCodeList;
16 |
17 | @property (nonatomic, weak ) UIView *proviceCodeView;
18 |
19 | @property (nonatomic, strong ) UIColor *deleteColor;
20 |
21 | @property (nonatomic, strong, nullable) NSBundle *thisBundle;
22 |
23 |
24 | @end
25 |
26 |
27 | @implementation YWProvinceLicensePlatePrefixView
28 |
29 |
30 |
31 |
32 | + (instancetype)getDefalutProvinceKeyBoardView:(id)textInput{
33 | return [[YWProvinceLicensePlatePrefixView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleDefault textInput:textInput];
34 | }
35 | - (instancetype)initWithFrame:(CGRect)frame
36 | inputViewStyle:(UIInputViewStyle)inputViewStyle
37 | textInput:(id)textInput{
38 | self = [super initWithFrame:frame inputViewStyle:inputViewStyle];
39 | if (self) {
40 | _textInput = textInput;
41 | [self createViewProviceCodeView];
42 | }
43 | return self;
44 | }
45 |
46 | - (void)createViewProviceCodeView{
47 |
48 | NSInteger lineItem = 10;
49 | CGFloat leftX = 5;
50 | CGFloat space = 6;
51 | NSInteger i = 0;
52 | CGFloat top = 5;
53 | CGFloat width = ([UIScreen mainScreen].bounds.size.width - (lineItem - 1) * space - leftX * 2)/lineItem;
54 | CGFloat height = 1.34375 * width;
55 |
56 | CGFloat viewHeight = 4 * (top * 2 + height);
57 | CGFloat both_x = YW_KEYBOARD_TABBARBOTTOM;
58 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight + both_x);
59 |
60 | [self addSubview:({
61 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewHeight)];
62 | _proviceCodeView = v;
63 | v;
64 | })];
65 | CGFloat fixedHeight = height + top + top;
66 |
67 | for (NSString *kText in self.proviceCodeList) {
68 | NSInteger index = i % lineItem;
69 | NSInteger page = i / lineItem;
70 | YWKeyboardButton *btn = [YWKeyboardButton buttonWithType:UIButtonTypeCustom];
71 | CGFloat currentX = index * (width + space) + leftX;
72 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
73 | if (i == 38){
74 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
75 | btn.tag = 902;
76 | btn.frame = CGRectMake(currentX, top + (height + top + top) * page, width * 2 + space, height);
77 | btn.keyColor = self.deleteColor;
78 | btn.delegate = self;
79 | }
80 | btn.input = kText;
81 | btn.textInput = _textInput;
82 | [_proviceCodeView addSubview:btn];
83 | i ++;
84 | }
85 | }
86 | //MARK: -------- YWKeyboardButtonDelegate -----------
87 | - (BOOL)needDrawAmplification:(YWKeyboardButton *)button{
88 | if (button.tag == 902) {
89 | return NO;
90 | }
91 | return YES;
92 | }
93 |
94 |
95 |
96 | //MARK: --- load YWKeyboardKit Bundle image ----
97 | - (UIImage *)getImageOnBundleWithImage:(NSString *)imageName{
98 | return [self getImageOnBundle:imageName ofType:@"png"];
99 | }
100 | - (UIImage *)getImageOnBundle:(NSString *)imageName
101 | ofType:(NSString *)type{
102 |
103 | return [UIImage imageNamed:imageName
104 | inBundle:self.thisBundle compatibleWithTraitCollection:nil];
105 |
106 | }
107 | //MARK: --- getter && setter
108 | - (NSBundle *)thisBundle{
109 | if (!_thisBundle) {
110 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
111 |
112 | NSURL *url = [bundle URLForResource:@"YWKeyboardKit"
113 | withExtension:@"bundle"];
114 |
115 | _thisBundle = [NSBundle bundleWithURL:url];
116 | }
117 | return _thisBundle;
118 | }
119 |
120 | - (NSMutableArray *)proviceCodeList{
121 | if (!_proviceCodeList) {
122 | _proviceCodeList = [NSMutableArray arrayWithArray:
123 | @[@"京",@"津",@"渝",@"沪",@"冀",@"晋",@"辽",@"吉",@"黑",@"苏",
124 | @"浙",@"皖",@"闽",@"赣",@"鲁",@"豫",@"鄂",@"湘",@"粤",@"琼",
125 | @"川",@"贵",@"云",@"陕",@"甘",@"青",@"蒙",@"桂",@"宁",@"新",
126 | @"藏",@"使",@"领",@"警",@"学",@"港",@"澳",@"挂", @""
127 | ]];
128 | }
129 | return _proviceCodeList;
130 | }
131 | - (UIColor *)deleteColor{
132 | if (!_deleteColor) {
133 | if (@available(iOS 13.0, *)) {
134 | _deleteColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
135 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
136 | return [UIColor colorWithRed:46.0/255.f green:46.0/255.f blue:46.0/255.f alpha:1];
137 | }else{
138 | return [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
139 | }
140 | }];
141 | } else {
142 | _deleteColor = [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
143 | }
144 | }
145 | return _deleteColor;
146 | }
147 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
148 | YWKeyboardButton *btn = [_proviceCodeView viewWithTag:902];
149 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
150 | }
151 | @end
152 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/NumPad/YWNumPadKeyboardView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWNumPadKeyboardView.h
3 | // HGWisdomRoad
4 | //
5 | // Created by yaowei on 2018/09/19.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWNumPadKeyboardView : UIInputView
13 |
14 | @property (nonatomic, weak, readonly) id textInput;
15 | /**是否需要按下变灰效果*/
16 | @property (nonatomic, assign ) BOOL downGrayEffect;
17 | /**是否只能输入有效数字【如有小数位,则保留2位数】默认NO*/
18 | @property (nonatomic, assign ) BOOL effectiveDigit;
19 | /**保留几位小数,默认保留2位数*/
20 | @property (nonatomic, assign ) NSInteger floatDigit;
21 |
22 | /**带有小数点圆角样式键盘*/
23 | + (instancetype)getDecimalKeyboardShadowView:(id)textInput;
24 | /**带有小数点分割线样式键盘*/
25 | + (instancetype)getDecimalKeyboardDividerView:(id)textInput;
26 |
27 | /**不带有小数点圆角样式键盘*/
28 | + (instancetype)getNumKeyboardShadowView:(id)textInput;
29 | /**不带有小数点分割线样式键盘*/
30 | + (instancetype)getNumKeyboardDividerView:(id)textInput;
31 |
32 |
33 | @end
34 |
35 | NS_ASSUME_NONNULL_END
36 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/NumPad/YWNumPadKeyboardView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWNumPadKeyboardView.m
3 | // HGWisdomRoad
4 | //
5 | // Created by yaowei on 2018/09/19.
6 | //
7 |
8 | #import "YWNumPadKeyboardView.h"
9 | #import
10 |
11 | @interface YWNumPadKeyboardView ()
12 | {
13 | CGFloat _itemWidth;
14 | NSInteger _cellType;
15 | CGFloat _space;
16 | }
17 | @property (nonatomic, strong, nullable) NSBundle *thisBundle;
18 |
19 | @property (nonatomic, strong ) NSMutableArray *numDecimalList;
20 | @property (nonatomic, strong ) NSMutableArray *numList;
21 | @property (nonatomic, strong ) UIColor *deleteColor;
22 | @property (nonatomic, strong, nullable) NSTimer *timer;
23 |
24 | @end
25 |
26 |
27 | @implementation YWNumPadKeyboardView
28 |
29 | /**带有小数点分割线样式键盘*/
30 | + (instancetype)getDecimalKeyboardDividerView:(id)textInput{
31 | YWNumPadKeyboardView *keyboardView = [[YWNumPadKeyboardView alloc] initWithFrame:CGRectZero
32 | inputViewStyle:UIInputViewStyleKeyboard
33 | textInput:textInput
34 | cellType:0];
35 | return keyboardView;
36 | }
37 | /**带有小数点圆角样式键盘*/
38 | + (instancetype)getDecimalKeyboardShadowView:(id)textInput{
39 | YWNumPadKeyboardView *keyboardView = [[YWNumPadKeyboardView alloc] initWithFrame:CGRectZero
40 | inputViewStyle:UIInputViewStyleKeyboard
41 | textInput:textInput
42 | cellType:1];
43 | return keyboardView;
44 | }
45 | /**不带有小数点分割线样式键盘*/
46 | + (instancetype)getNumKeyboardDividerView:(id)textInput{
47 | YWNumPadKeyboardView *keyboardView = [[YWNumPadKeyboardView alloc] initWithFrame:CGRectZero
48 | inputViewStyle:UIInputViewStyleKeyboard
49 | textInput:textInput
50 | cellType:2];
51 | return keyboardView;
52 | }
53 | /**不带有小数点圆角样式键盘*/
54 | + (instancetype)getNumKeyboardShadowView:(id)textInput{
55 | YWNumPadKeyboardView *keyboardView = [[YWNumPadKeyboardView alloc] initWithFrame:CGRectZero
56 | inputViewStyle:UIInputViewStyleKeyboard
57 | textInput:textInput
58 | cellType:3];
59 | return keyboardView;
60 |
61 | }
62 |
63 |
64 |
65 | - (instancetype)initWithFrame:(CGRect)frame
66 | inputViewStyle:(UIInputViewStyle)inputViewStyle
67 | textInput:(id)textInput
68 | cellType:(NSInteger)cellType{
69 | self = [super initWithFrame:frame inputViewStyle:inputViewStyle];
70 | if (self) {
71 | _cellType = cellType;
72 | _textInput = textInput;
73 | _space = 0.5;
74 | _downGrayEffect = YES;
75 | _floatDigit = 2;
76 | [self sizeToFit];
77 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
78 | [self createNumPadKeyboardView];
79 | }
80 | return self;
81 | }
82 |
83 | //MARK: --- YWKeyboardButtonDelegate ---
84 | - (BOOL)needDownGrayEffect:(YWKeyboardButton *)button{
85 | return _downGrayEffect;
86 | }
87 | //MARK: --- YWKeyboardButtonDataSource ---
88 | - (NSInteger)isEffectiveDigitForInput:(UIButton *)button{
89 | if (_effectiveDigit) {
90 | return _floatDigit;
91 | }
92 | return 0;
93 | }
94 | //MARK: --- UI ---
95 | - (void)createNumPadKeyboardView{
96 | if (_cellType == 0) {
97 | [self createDecimalKeyboardDividerView];
98 | return;
99 | }
100 | if (_cellType == 1) {
101 | [self createDecimalKeyboardShadowView];
102 | return;
103 | }
104 | if (_cellType == 2) {
105 | [self createNumKeyboardDividerView];
106 | return;
107 | }
108 | if (_cellType == 3) {
109 | [self createNumKeyboardShadowView];
110 | return;
111 | }
112 | }
113 | //MARK: --- 单元格圆角样式的view ---
114 | - (void)createDecimalKeyboardShadowView{
115 | NSInteger lineItem = 3;
116 | CGFloat space = _space;
117 | NSInteger i = 0;
118 | CGFloat top = 10;
119 | CGFloat width = _itemWidth;
120 | CGFloat height = 0.34 * width;
121 | CGFloat leftX = 10;
122 |
123 | for (NSString *kText in self.numDecimalList) {
124 | NSInteger index = i % lineItem;
125 | NSInteger page = i / lineItem;
126 | YWKeyboardDownButton *btn = [self createBtnWith:kText];
127 | CGFloat currentX = index * (width + space) + leftX;
128 | btn.frame = CGRectMake(currentX, top + (height + top) * page, width, height);
129 | btn.drawShadow = YES;
130 | [self addSubview:btn];
131 | i ++;
132 | }
133 | }
134 | - (void)createNumKeyboardShadowView{
135 | NSInteger lineItem = 3;
136 | CGFloat space = _space;
137 | NSInteger i = 0;
138 | CGFloat top = 10;
139 | CGFloat width = _itemWidth;
140 | CGFloat height = 0.34 * width;
141 | CGFloat leftX = 10;
142 |
143 | for (NSString *kText in self.numList) {
144 | NSInteger index = i % lineItem;
145 | NSInteger page = i / lineItem;
146 | YWKeyboardDownButton *btn = [self createBtnWith:kText];
147 | CGFloat currentX = index * (width + space) + leftX;
148 | if([kText isEqual:@"-"]){
149 | btn = nil;
150 | i ++;
151 | continue;;
152 | }else if([kText isEqual:@""]){//删除键
153 | btn.keyColor = [UIColor clearColor];
154 | btn.drawShadow = NO;
155 | btn.specificNoDown = YES;
156 | }
157 | btn.drawShadow = YES;
158 | btn.frame = CGRectMake(currentX, top + (height + top) * page, width, height);
159 | [self addSubview:btn];
160 | i ++;
161 | }
162 | }
163 | //MARK: --- 分割线样式的view ---
164 | - (void)createDecimalKeyboardDividerView{
165 | NSInteger lineItem = 3;
166 | CGFloat space = _space;
167 | NSInteger i = 0;
168 | CGFloat top = 0;
169 | CGFloat width = _itemWidth;
170 | CGFloat height = 0.34 * width;
171 | CGFloat fixedHeight = height + space;
172 | for (NSString *kText in self.numDecimalList) {
173 | NSInteger index = i % lineItem;
174 | NSInteger page = i / lineItem;
175 | YWKeyboardDownButton *btn = [self createBtnWith:kText];
176 | CGFloat currentX = index * (width + space);
177 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
178 | [self addSubview:btn];
179 | i ++;
180 | }
181 | }
182 | - (void)createNumKeyboardDividerView{
183 | NSInteger lineItem = 3;
184 | CGFloat space = _space;
185 | NSInteger i = 0;
186 | CGFloat top = 0;
187 | CGFloat width = _itemWidth;
188 | CGFloat height = 0.34 * width;
189 | CGFloat fixedHeight = height + space;
190 | for (NSString *kText in self.numList) {
191 | NSInteger index = i % lineItem;
192 | NSInteger page = i / lineItem;
193 | YWKeyboardDownButton *btn = [self createBtnWith:kText];
194 | CGFloat currentX = index * (width + space);
195 | if([kText isEqual:@"-"]){
196 | btn = nil;
197 | i ++;
198 | continue;;
199 | }else if([kText isEqual:@""]){
200 | btn.keyColor = [UIColor clearColor];
201 | btn.specificNoDown = YES;
202 | }
203 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
204 | [self addSubview:btn];
205 | i ++;
206 | }
207 | }
208 | - (YWKeyboardDownButton *)createBtnWith:(NSString *)kText{
209 | YWKeyboardDownButton *btn = [YWKeyboardDownButton buttonWithType:UIButtonTypeCustom];
210 | btn.drawShadow = NO;
211 | if ([kText isEqual:@""]) {
212 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
213 | btn.keyColor = self.deleteColor;
214 | btn.tag = 902;
215 | [self numPad_addLongGesAction:btn];
216 | }else if([kText isEqual:@"."]){
217 | btn.keyColor = self.deleteColor;
218 | }
219 | btn.delegate = self;
220 | btn.dataSource = self;
221 | btn.input = kText;
222 | btn.textInput = _textInput;
223 | return btn;
224 | }
225 | //MARK: --- 长按 delete ----
226 | - (void)numPad_addLongGesAction:(YWKeyboardDownButton *) btn{
227 | UILongPressGestureRecognizer *ges = [[UILongPressGestureRecognizer alloc] initWithTarget:self
228 | action:@selector(numPad_deleteWithLognGes:)];
229 | [btn addGestureRecognizer:ges];
230 | }
231 |
232 | - (void)numPad_deleteWithLognGes:(UILongPressGestureRecognizer *)sender{
233 | if (sender.state == UIGestureRecognizerStateBegan) {
234 | [self.timer invalidate];
235 | self.timer = nil;
236 | self.timer = [NSTimer timerWithTimeInterval:0.1
237 | target:self
238 | selector:@selector(numPad_deleteAction)
239 | userInfo:nil
240 | repeats:YES];
241 | [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
242 | }else if (sender.state == UIGestureRecognizerStateEnded){
243 | [self.timer invalidate];
244 | self.timer = nil;
245 | }
246 | }
247 | - (void)numPad_deleteAction{
248 | [self.textInput deleteBackward];
249 | }
250 | //MARK: --- load YWKeyboardKit Bundle image ----
251 | - (UIImage *)getImageOnBundleWithImage:(NSString *)imageName{
252 | return [self getImageOnBundle:imageName ofType:@"png"];
253 | }
254 | - (UIImage *)getImageOnBundle:(NSString *)imageName
255 | ofType:(NSString *)type{
256 |
257 | return [UIImage imageNamed:imageName
258 | inBundle:self.thisBundle compatibleWithTraitCollection:nil];
259 |
260 | }
261 |
262 | - (CGSize)sizeThatFits:(CGSize)size{
263 | CGSize sizeThatFit = [super sizeThatFits:size];
264 | CGFloat lbh = YW_KEYBOARD_TABBARBOTTOM;
265 | if (_cellType == 0 || _cellType == 2) {
266 | _space = 0.5;
267 | _itemWidth = ([UIScreen mainScreen].bounds.size.width - _space * 2)/3;
268 | CGFloat height = 0.34 * _itemWidth;
269 | sizeThatFit.height = height * 4 + lbh + _space * 3;
270 | }else if(_cellType == 1 || _cellType == 3){
271 | _space = 10;
272 | _itemWidth = ([UIScreen mainScreen].bounds.size.width - _space * 4)/3;
273 | CGFloat height = 0.34 * _itemWidth;
274 | sizeThatFit.height = height * 4 + (lbh > 0 ? lbh : 10) + _space * 4;
275 | }
276 | return sizeThatFit;
277 | }
278 |
279 | - (NSMutableArray *)numDecimalList{
280 | if (!_numDecimalList) {
281 | _numDecimalList = [NSMutableArray arrayWithArray:@[
282 | @"1",@"2",@"3",
283 | @"4",@"5",@"6",
284 | @"7",@"8",@"9",
285 | @".",@"0",@""
286 | ]];
287 | }
288 | return _numDecimalList;
289 | }
290 |
291 | - (NSMutableArray *)numList{
292 | if (!_numList) {
293 | _numList = [NSMutableArray arrayWithArray:@[
294 | @"1",@"2",@"3",
295 | @"4",@"5",@"6",
296 | @"7",@"8",@"9",
297 | @"-",@"0",@""
298 | ]];
299 | }
300 | return _numList;
301 | }
302 |
303 | - (NSBundle *)thisBundle{
304 | if (!_thisBundle) {
305 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
306 |
307 | NSURL *url = [bundle URLForResource:@"YWKeyboardKit"
308 | withExtension:@"bundle"];
309 |
310 | _thisBundle = [NSBundle bundleWithURL:url];
311 | }
312 | return _thisBundle;
313 | }
314 | - (UIColor *)deleteColor{
315 | if (!_deleteColor) {
316 | if (@available(iOS 13.0, *)) {
317 | _deleteColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
318 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
319 | return [UIColor colorWithRed:46.0/255.f green:46.0/255.f blue:46.0/255.f alpha:1];
320 | }else{
321 | return [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
322 | }
323 | }];
324 | } else {
325 | _deleteColor = [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
326 | }
327 | }
328 | return _deleteColor;
329 | }
330 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
331 | YWKeyboardButton *btn = [self viewWithTag:902];
332 | if (btn) {
333 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
334 | }
335 | }
336 | @end
337 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/NumSpecChara/YWNumSpencCharaKeyboardView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YWNumSpencCharaKeyboardView.h
3 | // Pods-YWKeyboardKit_Example
4 | //
5 | // Created by yaowei on 2020/12/23.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface YWNumSpencCharaKeyboardView : UIInputView
13 | @property (nonatomic, weak, readonly) id textInput;
14 | /**是否需要按下效果*/
15 | @property (nonatomic, assign ) BOOL downEffect;
16 |
17 | /// 获取UIInputViewview【字母+特殊字符】
18 | /// @param textInput 输入框
19 | + (instancetype)getDefalutNumCharKeyboardView:(id)textInput;
20 | /// 获取UIInputViewview【特殊字符+字母】
21 | /// @param textInput 输入框
22 | + (instancetype)getCharNumKeyboardView:(id)textInput;
23 |
24 | @end
25 |
26 | NS_ASSUME_NONNULL_END
27 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/NumSpecChara/YWNumSpencCharaKeyboardView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YWNumSpencCharaKeyboardView.m
3 | // Pods-YWKeyboardKit_Example
4 | //
5 | // Created by yaowei on 2020/12/23.
6 | //
7 |
8 | #import "YWNumSpencCharaKeyboardView.h"
9 | #import
10 |
11 | @interface YWNumSpencCharaKeyboardView ()
12 | {
13 | CGFloat _itemWidth;
14 | NSInteger _cellType;
15 | CGFloat _space;
16 | }
17 | @property (nonatomic, strong, nullable) NSBundle *thisBundle;
18 |
19 | @property (nonatomic, strong ) NSMutableArray *charList;
20 |
21 | @property (nonatomic, strong ) NSMutableArray *numPinList;
22 |
23 | @property (nonatomic, strong ) UIColor *deleteColor;
24 |
25 |
26 | @property (nonatomic, weak ) UIView *numPinView;
27 |
28 | @property (nonatomic, weak ) UIView *charView;
29 |
30 | @property (nonatomic, weak ) UIView *currentView;
31 |
32 | @property (nonatomic, strong, nullable) NSTimer *timer;
33 |
34 | @property (nonatomic, strong, nullable) NSMutableArray *letterList;
35 |
36 | @end
37 |
38 | @implementation YWNumSpencCharaKeyboardView
39 |
40 | /// 按下的回调
41 | /// @param button 当前操作对象
42 | - (void)handleTouchDownForState:(YWKeyboardButton *)button{
43 | if (button.tag == 801) {
44 | button.selected = !button.selected;
45 | if (button.selected) {
46 | button.keyColor = [UIColor whiteColor];
47 | button.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_up1_acc"];
48 | }else{
49 | button.keyColor = self.deleteColor;
50 | button.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_up_acc"];
51 | }
52 | for (YWKeyboardButton *btn in _letterList) {
53 | btn.selected = !btn.selected;
54 | }
55 | [button setNeedsDisplay];
56 | }
57 | }
58 | /**执行YWKeyboardButton内部的TouchUpInside,YES-继续执行内部的实现,NO-不需要执行*/
59 | - (BOOL)interceptorTouchUpInside:(UIButton *)button{
60 | if (button.tag == 801) {
61 | return NO;
62 | }
63 | if (button.tag == 901) {
64 | _currentView.hidden = YES;
65 | if (_currentView == self.numPinView) {
66 | [self createCharKeyboardView];
67 | }else{
68 | [self createNumCharKeyboardView];
69 | }
70 | _currentView.hidden = NO;
71 | [self.timer invalidate];
72 | self.timer = nil;
73 | return NO;
74 | }
75 |
76 | return YES;
77 | }
78 |
79 | /// 是否需要点击放大效果
80 | /// @param button 当前操作对象
81 | - (BOOL)needDrawAmplification:(UIButton *)button{
82 | if (button.tag == 801) {
83 | return NO;
84 | }
85 | if (button.tag == 901) {
86 | return NO;
87 | }
88 | if (button.tag == 902) {
89 | return NO;
90 | }
91 | if (button.tag == 999) {
92 | return NO;
93 | }
94 | return _downEffect;
95 | }
96 |
97 | + (instancetype)getDefalutNumCharKeyboardView:(id)textInput{
98 | return [[YWNumSpencCharaKeyboardView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput cellType:0];
99 | }
100 | + (instancetype)getCharNumKeyboardView:(id)textInput{
101 | return [[YWNumSpencCharaKeyboardView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard textInput:textInput cellType:1];
102 | }
103 | - (instancetype)initWithFrame:(CGRect)frame
104 | inputViewStyle:(UIInputViewStyle)inputViewStyle
105 | textInput:(id)textInput
106 | cellType:(NSInteger)cellType{
107 | self = [super initWithFrame:frame inputViewStyle:inputViewStyle];
108 | if (self) {
109 | _cellType = cellType;
110 | _textInput = textInput;
111 | _space = 0.5;
112 | _downEffect = YES;
113 | [self sizeToFit];
114 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
115 | if (cellType == 0) {
116 | [self createNumCharKeyboardView];
117 | }else{
118 | [self createCharKeyboardView];
119 | _currentView = _charView;
120 | }
121 | }
122 | return self;
123 | }
124 | - (void)createNumCharKeyboardView{
125 | if (_numPinView) {
126 | _currentView = _numPinView;
127 | return;
128 | }
129 | _letterList = [NSMutableArray new];
130 | NSInteger lineItem = 10;
131 | CGFloat leftX = 5;
132 | CGFloat space = 6;
133 | NSInteger i = 0;
134 | CGFloat top = 5;
135 | CGFloat width = _itemWidth;
136 | CGFloat height = 1.34375 * width;
137 |
138 | [self addSubview:({
139 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.frame.size.height)];
140 | _numPinView = v;
141 | v;
142 | })];
143 | CGFloat lastCurrentX = leftX;
144 | CGFloat fixedHeight = height + top + top;
145 | for (NSString *kText in self.numPinList) {
146 | NSInteger index = i % lineItem;
147 | NSInteger page = i / lineItem;
148 | YWKeyboardButton *btn = [YWKeyboardButton buttonWithType:UIButtonTypeCustom];
149 | if (i < 30) {
150 | CGFloat currentX = index == 0 ? leftX : lastCurrentX;
151 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
152 | lastCurrentX = currentX + width + space;
153 | }else if (i < 31){//字符切换
154 | CGFloat currentLeft = 1 * (width + space) + (width/2 + 6);//z的左距离
155 | CGFloat currentW = currentLeft - 5 - 10;
156 | CGFloat currentX = leftX;
157 | btn.frame = CGRectMake(currentX, top + fixedHeight * 3, currentW, height);
158 | lastCurrentX = currentX + currentW + space + space;
159 | }else if(i > 37){
160 | CGFloat currentZLeft = 1 * (width + space) + (width/2 + 6);//z的左距离
161 | CGFloat currentW = currentZLeft - 5 - 10;
162 | btn.frame = CGRectMake(lastCurrentX + space, top + fixedHeight * page, currentW, height);
163 | }else{
164 | CGFloat currentX = index == 0 ? leftX : lastCurrentX;
165 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
166 | lastCurrentX = currentX + width + space;
167 | }
168 | if (i == 20) {//大小切换切换
169 | btn.tag = 801;
170 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_up_acc"];
171 | }else if (i == 30) {//字符切换切换
172 | btn.tag = 901;
173 | btn.keyColor = self.deleteColor;
174 | [btn.titleLabel adjustsFontSizeToFitWidth];
175 | btn.input = kText;
176 | }else if (i == 38){
177 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
178 | btn.tag = 902;
179 | btn.keyColor = self.deleteColor;
180 | [self addLongGesAction:btn];
181 | }else{
182 | btn.input = [kText lowercaseString];
183 | btn.inputSelected = kText;
184 | }
185 | if (i > 9 && i < 20) {
186 | [_letterList addObject:btn];
187 | }else if (i > 20 && i < 30) {
188 | [_letterList addObject:btn];
189 | }else if (i > 30 && i < 38) {
190 | [_letterList addObject:btn];
191 | }
192 | btn.delegate = self;
193 | btn.textInput = _textInput;
194 | [_numPinView addSubview:btn];
195 | i ++;
196 | }
197 | _currentView = _numPinView;
198 | }
199 | - (void)createCharKeyboardView{
200 | if (_charView) {
201 | _currentView = _charView;
202 | return;
203 | }
204 |
205 | NSInteger lineItem = 10;
206 | CGFloat leftX = 5;
207 | CGFloat space = 6;
208 | NSInteger i = 0;
209 | CGFloat top = 5;
210 | CGFloat width = _itemWidth;
211 | CGFloat height = 1.34375 * width;
212 | CGSize mainSize = [UIScreen mainScreen].bounds.size;
213 | CGFloat totalWidth = mainSize.width;
214 |
215 | [self addSubview:({
216 | UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0,totalWidth, self.frame.size.height)];
217 | _charView = v;
218 | v;
219 | })];
220 |
221 | CGFloat lastCurrentX = leftX;
222 | CGFloat currentLeft = 1 * (width + space) + (width/2 + 6);//z的左距离
223 | CGFloat opationWith = currentLeft - 5 - 10;
224 | //针对小屏幕,处理字体
225 | CGSize size4 = CGSizeMake(320,568);
226 | UIFont *font = [UIFont systemFontOfSize:14];
227 | if (size4.width == mainSize.width && size4.height == mainSize.height) {//4.0
228 | font = [UIFont systemFontOfSize:12];
229 | }
230 |
231 | CGFloat fixedHeight = height + top + top;
232 |
233 | for (NSString *kText in self.charList) {
234 | NSInteger index = i % lineItem;
235 | NSInteger page = i / lineItem;
236 | YWKeyboardButton *btn = [YWKeyboardButton buttonWithType:UIButtonTypeCustom];
237 | if(i < 30){
238 | CGFloat currentX = index == 0 ? leftX : lastCurrentX;
239 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
240 | lastCurrentX = currentX + width + space;
241 | btn.input = kText;
242 | }else if (i == 30) {//abc
243 | CGFloat currentW = opationWith;
244 | CGFloat currentX = leftX;
245 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, currentW, height);
246 | lastCurrentX = currentX + currentW + space;
247 |
248 | btn.tag = 901;
249 | btn.keyColor = self.deleteColor;
250 | btn.titleLabel.font = font;
251 | btn.input = kText;
252 |
253 | }else if (i == 33){//空格
254 | btn.tag = 999;
255 | CGFloat currentW = totalWidth - lastCurrentX - 2 *(space + width) - space - opationWith - leftX;
256 | CGFloat currentX = lastCurrentX;
257 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, currentW, height);
258 | lastCurrentX = currentX + currentW + space;
259 | btn.input = kText;
260 | [btn setTitle:@"空格" forState:UIControlStateNormal];
261 | [btn setTitle:@"空格" forState:UIControlStateDisabled];
262 | [btn setTitle:@"空格" forState:UIControlStateSelected];
263 | }else if(i == 36){//delete
264 | CGFloat currentW = opationWith;
265 | btn.frame = CGRectMake(lastCurrentX, top + fixedHeight * page, currentW, height);
266 |
267 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
268 | btn.tag = 902;
269 | btn.keyColor = self.deleteColor;
270 | [self addLongGesAction:btn];
271 | }else{
272 | CGFloat currentX = index == 0 ? leftX : lastCurrentX;
273 | btn.frame = CGRectMake(currentX, top + fixedHeight * page, width, height);
274 | lastCurrentX = currentX + width + space;
275 | btn.input = kText;
276 | }
277 | btn.delegate = self;
278 | btn.textInput = _textInput;
279 | [_charView addSubview:btn];
280 | i ++;
281 | }
282 | _currentView = _charView;
283 | }
284 | - (CGSize)sizeThatFits:(CGSize)size{
285 | CGSize sizeThatFit = [super sizeThatFits:size];
286 |
287 | NSInteger lineItem = 10;
288 | CGFloat leftX = 5;
289 | CGFloat space = 6;
290 | CGFloat top = 5;
291 | _itemWidth = ([UIScreen mainScreen].bounds.size.width - (lineItem - 1) * space - leftX * 2)/lineItem;
292 | CGFloat height = 1.34375 * _itemWidth;
293 |
294 | CGFloat viewHeight = 4 * (top * 2 + height);
295 | CGFloat both_x = YW_KEYBOARD_TABBARBOTTOM;
296 | sizeThatFit.height = viewHeight + both_x;
297 |
298 | return sizeThatFit;;
299 | }
300 |
301 | //MARK: --- load YWKeyboardKit Bundle image ----
302 | - (UIImage *)getImageOnBundleWithImage:(NSString *)imageName{
303 | return [self getImageOnBundle:imageName ofType:@"png"];
304 | }
305 | - (UIImage *)getImageOnBundle:(NSString *)imageName
306 | ofType:(NSString *)type{
307 |
308 | return [UIImage imageNamed:imageName
309 | inBundle:self.thisBundle compatibleWithTraitCollection:nil];
310 |
311 | }
312 | //MARK: --- 长按 delete ----
313 | - (void)addLongGesAction:(YWKeyboardButton *) btn{
314 | UILongPressGestureRecognizer *ges = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(deleteWithLognGes:)];
315 | [btn addGestureRecognizer:ges];
316 | }
317 |
318 | - (void)deleteWithLognGes:(UILongPressGestureRecognizer *)sender{
319 | if (sender.state == UIGestureRecognizerStateBegan) {
320 | [self.timer invalidate];
321 | self.timer = nil;
322 | self.timer = [NSTimer timerWithTimeInterval:0.1
323 | target:self
324 | selector:@selector(deleteAction)
325 | userInfo:nil
326 | repeats:YES];
327 | [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
328 | }else if (sender.state == UIGestureRecognizerStateEnded){
329 | [self.timer invalidate];
330 | self.timer = nil;
331 | }
332 | }
333 | - (void)deleteAction{
334 | [self.textInput deleteBackward];
335 | }
336 | - (NSMutableArray *)numPinList{
337 | if (!_numPinList) {
338 | _numPinList = [NSMutableArray arrayWithArray:@[
339 | @"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"0",
340 | @"Q",@"W",@"E",@"R",@"T",@"Y",@"U",@"I",@"O",@"P",
341 | @"up",@"A",@"S",@"D",@"F",@"G",@"H",@"J",@"K",@"L",
342 | @"#+=",@"Z",@"X",@"C",@"V",@"B",@"N",@"M",@""
343 | ]];
344 | }
345 | return _numPinList;
346 | }
347 | - (NSMutableArray *)charList{
348 | if (!_charList) {
349 | _charList = [NSMutableArray arrayWithArray:@[
350 | @"&",@"\"",@";",@"^",@",",@"|",@"$",@"*",@":",@"'",
351 | @"?",@"{",@"[",@"~",@"#",@"}",@".",@"]",@"\\",@"!",
352 | @"(",@"%",@"-",@"_",@"+",@"/",@")",@"=",@"<",@"`",
353 | @"ABC",@">",@"@",@" ",@"·",@"¥",@""
354 | ]];
355 | }
356 | return _charList;
357 | }
358 | - (NSBundle *)thisBundle{
359 | if (!_thisBundle) {
360 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
361 |
362 | NSURL *url = [bundle URLForResource:@"YWKeyboardKit"
363 | withExtension:@"bundle"];
364 |
365 | _thisBundle = [NSBundle bundleWithURL:url];
366 | }
367 | return _thisBundle;
368 | }
369 | - (UIColor *)deleteColor{
370 | if (!_deleteColor) {
371 | if (@available(iOS 13.0, *)) {
372 | _deleteColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
373 | if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
374 | return [UIColor colorWithRed:46.0/255.f green:46.0/255.f blue:46.0/255.f alpha:1];
375 | }else{
376 | return [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
377 | }
378 | }];
379 | } else {
380 | _deleteColor = [UIColor colorWithRed:180.0/255.f green:186.0/255.f blue:197.0/255.f alpha:1];
381 | }
382 | }
383 | return _deleteColor;
384 | }
385 | - (void)dealloc{
386 | [_letterList removeAllObjects];
387 | _letterList = nil;
388 | }
389 |
390 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
391 | YWKeyboardButton *btn2 = [_numPinView viewWithTag:801];
392 | YWKeyboardButton *btn = [_numPinView viewWithTag:902];
393 | YWKeyboardButton *btn1 = [_charView viewWithTag:902];
394 | if (btn) {
395 | btn.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
396 | }
397 | if (btn1) {
398 | btn1.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_over"];
399 | }
400 | if (btn2) {
401 | btn2.iconImage = [self getImageOnBundleWithImage:@"yw_keyboard_up_acc"];
402 | }
403 | }
404 | @end
405 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/TurtleBezierPath/TurtleBezierPath.h:
--------------------------------------------------------------------------------
1 | //
2 | // TurtleBezierPath.h
3 | // TurtleBezierPath demo
4 | //
5 | // Created by Nigel Barber on 09/12/2013.
6 | // Copyright (c) 2013 Nigel Barber. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface TurtleBezierPath : UIBezierPath
12 |
13 | @property( nonatomic, assign ) CGFloat bearing;
14 | @property( nonatomic, assign ) BOOL penUp;
15 |
16 | -(CGRect)boundsWithStroke;
17 | -(CGRect)boundsForView;
18 |
19 | -(void)home;
20 | -(void)forward:(CGFloat)distance;
21 | -(void)turn:(CGFloat)angle;
22 | -(void)leftArc:(CGFloat)radius turn:(CGFloat)angle;
23 | -(void)rightArc:(CGFloat)radius turn:(CGFloat)angle;
24 | -(void)down;
25 | -(void)up;
26 |
27 | -(void)centreInBounds:(CGRect)bounds;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/YWKeyboardKit/Classes/TurtleBezierPath/TurtleBezierPath.m:
--------------------------------------------------------------------------------
1 | //
2 | // TurtleBezierPath.m
3 | // TurtleBezierPath demo
4 | //
5 | // Created by Nigel Barber on 09/12/2013.
6 | // Copyright (c) 2013 Nigel Barber. All rights reserved.
7 | //
8 |
9 | #import "TurtleBezierPath.h"
10 |
11 | @implementation TurtleBezierPath
12 |
13 |
14 | #pragma mark - NSCoding
15 |
16 | -(void)encodeWithCoder:(NSCoder *)aCoder
17 | {
18 | [ super encodeWithCoder:aCoder ];
19 |
20 | [ aCoder encodeFloat:self.bearing forKey:@"bearing" ];
21 | [ aCoder encodeBool:self.penUp forKey:@"penUp" ];
22 | }
23 |
24 | - (id)initWithCoder:(NSCoder *)aDecoder
25 | {
26 | if( self = [ super initWithCoder:aDecoder ])
27 | {
28 | self.bearing = [ aDecoder decodeFloatForKey:@"bearing" ];
29 | self.penUp = [ aDecoder decodeBoolForKey:@"penUp" ];
30 | }
31 |
32 | return self;
33 | }
34 |
35 |
36 | #pragma mark - NSCopying
37 |
38 | -(id)copyWithZone:(NSZone *)zone
39 | {
40 | TurtleBezierPath *clone = [[ TurtleBezierPath allocWithZone:zone ] init ];
41 | clone.CGPath = self.CGPath;
42 | clone.lineCapStyle = self.lineCapStyle;
43 | clone.lineJoinStyle = self.lineJoinStyle;
44 | clone.lineWidth = self.lineWidth;
45 | clone.miterLimit = self.miterLimit;
46 | clone.flatness = self.flatness;
47 | clone.usesEvenOddFillRule = self.usesEvenOddFillRule;
48 |
49 | CGFloat phase;
50 | NSInteger count;
51 | [ self getLineDash:nil count:&count phase:&phase ];
52 | CGFloat *lineDash = malloc( count * sizeof( CGFloat ));
53 | [ self getLineDash:lineDash count:&count phase:&phase ];
54 | [ clone setLineDash:lineDash count:count phase:phase ];
55 | free( lineDash );
56 |
57 | clone.bearing = self.bearing;
58 | clone.penUp = self.penUp;
59 |
60 | return clone;
61 | }
62 |
63 |
64 | #pragma mark - Private methods
65 |
66 | -(void)arc:(CGFloat)radius turn:(CGFloat)angle clockwise:(BOOL)clockwise
67 | {
68 | CGFloat radiusTurn = ( clockwise ) ? 90.0f : -90.0f;
69 | CGFloat cgAngleBias = ( clockwise ) ? 180.0f : 0.0f;
70 | angle = ( clockwise ) ? angle : -angle;
71 |
72 | CGPoint centre = [ self toCartesian:radius bearing:self.bearing + radiusTurn origin:self.currentPoint ];
73 |
74 | CGFloat cgStartAngle = cgAngleBias + self.bearing;
75 | CGFloat cgEndAngle = cgAngleBias + ( self.bearing + angle );
76 |
77 | self.bearing += angle;
78 | CGPoint endPoint = [ self toCartesian:radius bearing:( self.bearing -radiusTurn ) origin:centre ];
79 |
80 | if( self.penUp )
81 | {
82 | [ self moveToPoint:endPoint ];
83 | }
84 | else
85 | {
86 | [ self addArcWithCenter:centre radius:radius startAngle:radians( cgStartAngle ) endAngle:radians( cgEndAngle ) clockwise:clockwise ];
87 | }
88 | }
89 |
90 |
91 | #pragma mark - Public methods
92 |
93 | -(CGRect)boundsWithStroke
94 | {
95 | return CGRectIntegral( CGRectInset( self.bounds, -self.lineWidth * 0.5f, -self.lineWidth * 0.5f ));
96 | }
97 |
98 | -(CGRect)boundsForView
99 | {
100 | CGRect bounds = self.boundsWithStroke;
101 | CGFloat maxWidth = MAX( fabs( CGRectGetMinX( bounds )), fabs( CGRectGetMaxX( bounds )));
102 | CGFloat maxHeight = MAX( fabs( CGRectGetMinY( bounds )), fabs(CGRectGetMaxY( bounds )));
103 |
104 | return CGRectMake( 0.0f, 0.0f, maxWidth * 2.0f, maxHeight * 2.0f );
105 | }
106 |
107 | -(BOOL)isEqual:(TurtleBezierPath *)aPath
108 | {
109 | if (@available(iOS 12.0, *)) {
110 | return [[NSKeyedArchiver archivedDataWithRootObject:self requiringSecureCoding:YES error:nil] isEqualToData:[NSKeyedArchiver archivedDataWithRootObject:aPath requiringSecureCoding:YES error:nil]];
111 | } else {
112 | return [[ NSKeyedArchiver archivedDataWithRootObject:self ] isEqualToData:[ NSKeyedArchiver archivedDataWithRootObject:aPath ]];
113 | }
114 |
115 |
116 | }
117 |
118 | -(void)home
119 | {
120 | [ self moveToPoint:CGPointZero ];
121 | self.bearing = 0.0f;
122 | }
123 |
124 | -(void)forward:(CGFloat)distance
125 | {
126 | CGPoint endPoint = [ self toCartesian:distance bearing:self.bearing origin:self.currentPoint ];
127 |
128 | if( self.penUp )
129 | {
130 | [ self moveToPoint:endPoint ];
131 | }
132 | else
133 | {
134 | [ self addLineToPoint:endPoint ];
135 | }
136 | }
137 |
138 | -(void)turn:(CGFloat)angle
139 | {
140 | self.bearing += angle;
141 | }
142 |
143 | -(void)leftArc:(CGFloat)radius turn:(CGFloat)angle
144 | {
145 | [ self arc:radius turn:angle clockwise:NO ];
146 | }
147 |
148 | -(void)rightArc:(CGFloat)radius turn:(CGFloat)angle
149 | {
150 | [ self arc:radius turn:angle clockwise:YES ];
151 | }
152 |
153 | -(void)down
154 | {
155 | self.penUp = NO;
156 | }
157 |
158 | -(void)up
159 | {
160 | self.penUp = YES;
161 | }
162 |
163 | -(void)centreInBounds:(CGRect)bounds
164 | {
165 | [ self applyTransform:CGAffineTransformMakeTranslation( bounds.size.width / 2.0f, bounds.size.height / 2.0f )];
166 | }
167 |
168 |
169 | #pragma mark - Maths
170 |
171 | static inline CGFloat radians (CGFloat degrees) {return degrees * M_PI / 180.0;}
172 |
173 | -(CGPoint)toCartesian:(CGFloat)radius bearing:(CGFloat)bearing origin:(CGPoint)origin
174 | {
175 | CGFloat bearingInRadians = radians( bearing );
176 |
177 | CGPoint vector = CGPointMake( radius * sinf( bearingInRadians ), -radius * cosf( bearingInRadians ));
178 |
179 | return CGPointMake( origin.x + vector.x, origin.y + vector.y );
180 | }
181 |
182 |
183 | @end
184 |
--------------------------------------------------------------------------------
/_Pods.xcodeproj:
--------------------------------------------------------------------------------
1 | Example/Pods/Pods.xcodeproj
--------------------------------------------------------------------------------
/image_re/id_card_1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/id_card_1@2x.png
--------------------------------------------------------------------------------
/image_re/id_card_2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/id_card_2@2x.png
--------------------------------------------------------------------------------
/image_re/num_char1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/num_char1@2x.png
--------------------------------------------------------------------------------
/image_re/num_char2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/num_char2@2x.png
--------------------------------------------------------------------------------
/image_re/num_pad_1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/num_pad_1@2x.png
--------------------------------------------------------------------------------
/image_re/num_pad_2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/num_pad_2@2x.png
--------------------------------------------------------------------------------
/image_re/plate_1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/plate_1@2x.png
--------------------------------------------------------------------------------
/image_re/plate_2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/plate_2@2x.png
--------------------------------------------------------------------------------
/image_re/plate_3@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flyOfYW/YWKeyboardKit/e1019d597fa096dff9cb994c1113841544c18686/image_re/plate_3@2x.png
--------------------------------------------------------------------------------