├── Design
├── Example.png
├── Showcase.gif
├── Screencast.png
└── Customkeyboard.png
├── CustomKeyboard
├── Resources
│ └── CustomKeyboard.xcassets
│ │ ├── Contents.json
│ │ ├── Keyboard_DismissKey.imageset
│ │ ├── Keyboard_DismissKey.png
│ │ ├── Keyboard_DismissKey@2x.png
│ │ ├── Keyboard_DismissKey@3x.png
│ │ └── Contents.json
│ │ └── Keyboard_Backspace.imageset
│ │ ├── Keyboard_Backspace@2x.png
│ │ ├── Keyboard_Backspace@3x.png
│ │ └── Contents.json
└── Classes
│ └── CustomKeyboard.swift
├── CustomKeyboardExample
├── CustomKeyboardExample.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ └── project.pbxproj
└── CustomKeyboardExample
│ ├── ViewController.swift
│ ├── Info.plist
│ ├── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.storyboard
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ └── AppDelegate.swift
├── LICENSE
├── .gitignore
├── README.md
└── Customkeyboard.podspec
/Design/Example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/Design/Example.png
--------------------------------------------------------------------------------
/Design/Showcase.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/Design/Showcase.gif
--------------------------------------------------------------------------------
/Design/Screencast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/Design/Screencast.png
--------------------------------------------------------------------------------
/Design/Customkeyboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/Design/Customkeyboard.png
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey.png
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_Backspace.imageset/Keyboard_Backspace@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_Backspace.imageset/Keyboard_Backspace@2x.png
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_Backspace.imageset/Keyboard_Backspace@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_Backspace.imageset/Keyboard_Backspace@3x.png
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey@2x.png
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevLiuSir/CustomKeyboard/HEAD/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Keyboard_DismissKey@3x.png
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_Backspace.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "Keyboard_Backspace@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "Keyboard_Backspace@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/CustomKeyboard/Resources/CustomKeyboard.xcassets/Keyboard_DismissKey.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "Keyboard_DismissKey.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "Keyboard_DismissKey@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "Keyboard_DismissKey@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Mr Liu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // CustomKeyboardExample
4 | //
5 | // Created by Liu Chuan on 2017/12/26.
6 | // Copyright © 2017年 LC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | /// 淡蓝色
12 | let lightBlue = UIColor(red:0.45, green:0.69, blue:0.95, alpha:1.00)
13 |
14 | class ViewController: UIViewController {
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | view.backgroundColor = UIColor.gray
20 |
21 | example()
22 | }
23 | /// 例子
24 | private func example() {
25 | /// 文本框
26 | let textField = UITextField(frame: CGRect(x: 100, y: 120, width: 200, height: 35))
27 | textField.borderStyle = .roundedRect
28 | view.addSubview(textField)
29 |
30 | /* -- CustomKeyboard --- */
31 | let keyboard = CustomKeyboard(view, field: textField)
32 | keyboard.keyboardStyle = .number
33 | keyboard.isEnableKeyboard = true
34 | keyboard.whetherHighlight = true
35 | keyboard.frame.size.height = 300
36 | keyboard.customDoneButton(title: "确定", titleColor: .white, theme: lightBlue, target: self, callback: nil)
37 | textField.becomeFirstResponder()
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | .build/
41 |
42 | # CocoaPods
43 | #
44 | # We recommend against adding the Pods directory to your .gitignore. However
45 | # you should judge for yourself, the pros and cons are mentioned at:
46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47 | #
48 | # Pods/
49 |
50 | # Carthage
51 | #
52 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
53 | # Carthage/Checkouts
54 |
55 | Carthage/Build
56 |
57 | # fastlane
58 | #
59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
60 | # screenshots whenever they are needed.
61 | # For more information about the recommended setup visit:
62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
63 |
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/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 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/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 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // CustomKeyboardExample
4 | //
5 | // Created by Liu Chuan on 2018/1/23.
6 | // Copyright © 2018年 LC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
Customkeyboard is a simple and fast framework for custom digital keyboards. There's always a keyboard for you.
3 |
4 |
5 | ---
6 | 
7 | [](https://developer.apple.com/swift/)
8 | 
9 | 
10 | 
11 | 
12 | 
13 | 
14 | 
15 | 
16 | 
17 | 
18 | 
19 | 
20 | [](https://twitter.com/LiuChuan_)
21 |
22 |
23 |
24 |
25 | ## Design
26 |
27 | 
28 |
29 |
30 | ## Requirements
31 | - iOS 12.0 +
32 | - Xcode 10 +
33 | - Swift 5.0 +
34 |
35 | ## Installation
36 |
37 | [CocoaPods](http://cocoapods.org/) is a dependency manager for Cocoa projects. You can install it with the following command:
38 |
39 | ```swift
40 | $ gem install cocoapods
41 | ```
42 |
43 |
44 | Just add the `Customkeyboard` folder to your project.
45 |
46 | or use `CocoaPods` with Podfile:
47 |
48 | ```swift
49 | pod 'Customkeyboard'
50 | ```
51 |
52 | You can use CocoaPods to install `Customkeyboard` by adding it to your Podfile:
53 |
54 |
55 | ```swift
56 | platform :ios, '12.0'
57 | target '' do
58 | use_frameworks!
59 | pod 'Customkeyboard'
60 | end
61 | ```
62 |
63 |
64 |
65 | Then, run the following command:
66 |
67 | ```swift
68 | $ pod install
69 | ```
70 |
71 | ## Revision
72 | - Add button sound
73 | - Add long press to delete
74 |
75 |
76 | ## Example
77 | 
78 |
79 |
80 |
81 | ## Author
82 | | [
](https://github.com/DevLiuSir) | [Mr Liu](https://github.com/DevLiuSir)
Software Engineer
[![Twitter][1.1]][1] [![Github][2.1]][2] [![LinkedIn][3.1]][3] |
83 | | :------------: | :------------: |
84 |
85 | [1.1]: http://i.imgur.com/wWzX9uB.png (twitter icon without padding)
86 | [2.1]: http://i.imgur.com/9I6NRUm.png (github icon without padding)
87 | [3.1]: https://www.kingsfund.org.uk/themes/custom/kingsfund/dist/img/svg/sprite-icon-linkedin.svg (linkedin icon)
88 |
89 | [1]: https://twitter.com/LiuChuan_
90 | [2]: https://github.com/DevLiuSir
91 | [3]: https://www.linkedin.com/in/chuan-liu-00359115a/
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/Customkeyboard.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint Customkeyboard.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "Customkeyboard"
19 | s.version = "5.0.0"
20 | s.swift_version = "5.0"
21 | s.summary = "A simple and fast realization of a custom keyboard."
22 |
23 | # This description is used to generate tags and improve search results.
24 | # * Think: What does it do? Why did you write it? What is the focus?
25 | # * Try to keep it short, snappy and to the point.
26 | # * Write the description between the DESC delimiters below.
27 | # * Finally, don't worry about the indent, CocoaPods strips it!
28 | s.description = <<-DESC
29 | A simple and fast realization of a custom digital keyboard. There is always a keyboard for you.
30 | DESC
31 |
32 | s.homepage = "https://github.com/ChinaHackers/CustomKeyboard"
33 | s.screenshots = "https://github.com/ChinaHackers/CustomKeyboard/raw/master/Screencast/Screencast.png"
34 |
35 |
36 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
37 | #
38 | # Licensing your code is important. See http://choosealicense.com for more info.
39 | # CocoaPods will detect a license file if there is a named LICENSE*
40 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
41 | #
42 |
43 | s.license = "MIT"
44 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
45 |
46 |
47 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
48 | #
49 | # Specify the authors of the library, with email addresses. Email addresses
50 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
51 | # accepts just a name if you'd rather not provide an email address.
52 | #
53 | # Specify a social_media_url where others can refer to, for example a twitter
54 | # profile URL.
55 | #
56 |
57 | s.author = { "ChinaHackers" => "93428739@qq.com" }
58 | # Or just: s.author = "ChinaHackers"
59 | # s.authors = { "ChinaHackers" => "93428739@qq.com" }
60 | # s.social_media_url = "http://twitter.com/LiuChuan_"
61 |
62 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
63 | #
64 | # If this Pod runs only on iOS or OS X, then specify the platform and
65 | # the deployment target. You can optionally include the target after the platform.
66 | #
67 |
68 | # s.platform = :ios
69 | # s.platform = :ios, "5.0"
70 |
71 | # When using multiple platforms
72 | s.ios.deployment_target = "12.0"
73 | # s.osx.deployment_target = "10.7"
74 | # s.watchos.deployment_target = "2.0"
75 | # s.tvos.deployment_target = "9.0"
76 |
77 |
78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
79 | #
80 | # Specify the location from where the source should be retrieved.
81 | # Supports git, hg, bzr, svn and HTTP.
82 | #
83 |
84 | s.source = { :git => "https://github.com/ChinaHackers/CustomKeyboard.git", :tag => "#{s.version}" }
85 |
86 |
87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
88 | #
89 | # CocoaPods is smart about how it includes source code. For source files
90 | # giving a folder will include any swift, h, m, mm, c & cpp files.
91 | # For header files it will include any header in the folder.
92 | # Not including the public_header_files will make all headers public.
93 | #
94 |
95 | s.source_files = "CustomKeyboard", "CustomKeyboard/Classes/**/*.{h,m,swift}"
96 | s.exclude_files = "CustomKeyboard/Exclude"
97 |
98 | # s.public_header_files = "Classes/**/*.h"
99 |
100 |
101 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
102 | #
103 | # A list of resources included with the Pod. These are copied into the
104 | # target bundle with a build phase script. Anything else will be cleaned.
105 | # You can preserve files from being cleaned, please don't preserve
106 | # non-essential files like tests, examples and documentation.
107 | #
108 |
109 | # s.resource = "icon.png"
110 | # s.resources = "CustomKeyboard/Resources/*.png"
111 | s.resource_bundles = {
112 | 'CustomKeyboard' => ['CustomKeyboard/Resources/*.xcassets']
113 | }
114 |
115 |
116 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
117 |
118 |
119 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
120 | #
121 | # Link your library with frameworks, or libraries. Libraries do not include
122 | # the lib prefix of their name.
123 | #
124 |
125 | s.framework = "UIKit"
126 | # s.frameworks = "SomeFramework", "AnotherFramework"
127 |
128 | # s.library = "iconv"
129 | # s.libraries = "iconv", "xml2"
130 |
131 |
132 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
133 | #
134 | # If your library depends on compiler flags you can set them in the xcconfig hash
135 | # where they will only apply to your library. If you depend on other Podspecs
136 | # you can include multiple dependencies to ensure it works.
137 |
138 | # s.requires_arc = true
139 |
140 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
141 | # s.dependency "JSONKit", "~> 1.4"
142 |
143 | end
144 |
--------------------------------------------------------------------------------
/CustomKeyboardExample/CustomKeyboardExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 6B182C08227C144500643783 /* CustomKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B182C00227C144400643783 /* CustomKeyboard.swift */; };
11 | 6B182C09227C144500643783 /* CustomKeyboard.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C02227C144400643783 /* CustomKeyboard.bundle */; };
12 | 6B182C0A227C144500643783 /* Keyboard_Backspace@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C03227C144400643783 /* Keyboard_Backspace@2x.png */; };
13 | 6B182C0B227C144500643783 /* Keyboard_Backspace@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C04227C144400643783 /* Keyboard_Backspace@3x.png */; };
14 | 6B182C0C227C144500643783 /* Keyboard_DismissKey.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C05227C144400643783 /* Keyboard_DismissKey.png */; };
15 | 6B182C0D227C144500643783 /* Keyboard_DismissKey@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C06227C144400643783 /* Keyboard_DismissKey@2x.png */; };
16 | 6B182C0E227C144500643783 /* Keyboard_DismissKey@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6B182C07227C144400643783 /* Keyboard_DismissKey@3x.png */; };
17 | 6B9CDF1D201789B800974C42 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B9CDF1C201789B800974C42 /* AppDelegate.swift */; };
18 | 6B9CDF1F201789B800974C42 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B9CDF1E201789B800974C42 /* ViewController.swift */; };
19 | 6B9CDF22201789B800974C42 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B9CDF20201789B800974C42 /* Main.storyboard */; };
20 | 6B9CDF24201789B800974C42 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B9CDF23201789B800974C42 /* Assets.xcassets */; };
21 | 6B9CDF27201789B800974C42 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B9CDF25201789B800974C42 /* LaunchScreen.storyboard */; };
22 | /* End PBXBuildFile section */
23 |
24 | /* Begin PBXFileReference section */
25 | 6B182C00227C144400643783 /* CustomKeyboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomKeyboard.swift; sourceTree = ""; };
26 | 6B182C02227C144400643783 /* CustomKeyboard.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = CustomKeyboard.bundle; sourceTree = ""; };
27 | 6B182C03227C144400643783 /* Keyboard_Backspace@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Keyboard_Backspace@2x.png"; sourceTree = ""; };
28 | 6B182C04227C144400643783 /* Keyboard_Backspace@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Keyboard_Backspace@3x.png"; sourceTree = ""; };
29 | 6B182C05227C144400643783 /* Keyboard_DismissKey.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Keyboard_DismissKey.png; sourceTree = ""; };
30 | 6B182C06227C144400643783 /* Keyboard_DismissKey@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Keyboard_DismissKey@2x.png"; sourceTree = ""; };
31 | 6B182C07227C144400643783 /* Keyboard_DismissKey@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Keyboard_DismissKey@3x.png"; sourceTree = ""; };
32 | 6B9CDF19201789B800974C42 /* CustomKeyboardExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomKeyboardExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
33 | 6B9CDF1C201789B800974C42 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
34 | 6B9CDF1E201789B800974C42 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
35 | 6B9CDF21201789B800974C42 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
36 | 6B9CDF23201789B800974C42 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
37 | 6B9CDF26201789B800974C42 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
38 | 6B9CDF28201789B800974C42 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | /* End PBXFileReference section */
40 |
41 | /* Begin PBXFrameworksBuildPhase section */
42 | 6B9CDF16201789B800974C42 /* Frameworks */ = {
43 | isa = PBXFrameworksBuildPhase;
44 | buildActionMask = 2147483647;
45 | files = (
46 | );
47 | runOnlyForDeploymentPostprocessing = 0;
48 | };
49 | /* End PBXFrameworksBuildPhase section */
50 |
51 | /* Begin PBXGroup section */
52 | 6B182BFE227C144400643783 /* CustomKeyboard */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 6B182BFF227C144400643783 /* Classes */,
56 | 6B182C01227C144400643783 /* Resources */,
57 | );
58 | name = CustomKeyboard;
59 | path = ../../CustomKeyboard;
60 | sourceTree = "";
61 | };
62 | 6B182BFF227C144400643783 /* Classes */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 6B182C00227C144400643783 /* CustomKeyboard.swift */,
66 | );
67 | path = Classes;
68 | sourceTree = "";
69 | };
70 | 6B182C01227C144400643783 /* Resources */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 6B182C02227C144400643783 /* CustomKeyboard.bundle */,
74 | 6B182C03227C144400643783 /* Keyboard_Backspace@2x.png */,
75 | 6B182C04227C144400643783 /* Keyboard_Backspace@3x.png */,
76 | 6B182C05227C144400643783 /* Keyboard_DismissKey.png */,
77 | 6B182C06227C144400643783 /* Keyboard_DismissKey@2x.png */,
78 | 6B182C07227C144400643783 /* Keyboard_DismissKey@3x.png */,
79 | );
80 | path = Resources;
81 | sourceTree = "";
82 | };
83 | 6B9CDF10201789B800974C42 = {
84 | isa = PBXGroup;
85 | children = (
86 | 6B9CDF1B201789B800974C42 /* CustomKeyboardExample */,
87 | 6B9CDF1A201789B800974C42 /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | 6B9CDF1A201789B800974C42 /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | 6B9CDF19201789B800974C42 /* CustomKeyboardExample.app */,
95 | );
96 | name = Products;
97 | sourceTree = "";
98 | };
99 | 6B9CDF1B201789B800974C42 /* CustomKeyboardExample */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 6B182BFE227C144400643783 /* CustomKeyboard */,
103 | 6B9CDF1C201789B800974C42 /* AppDelegate.swift */,
104 | 6B9CDF1E201789B800974C42 /* ViewController.swift */,
105 | 6B9CDF20201789B800974C42 /* Main.storyboard */,
106 | 6B9CDF23201789B800974C42 /* Assets.xcassets */,
107 | 6B9CDF25201789B800974C42 /* LaunchScreen.storyboard */,
108 | 6B9CDF28201789B800974C42 /* Info.plist */,
109 | );
110 | path = CustomKeyboardExample;
111 | sourceTree = "";
112 | };
113 | /* End PBXGroup section */
114 |
115 | /* Begin PBXNativeTarget section */
116 | 6B9CDF18201789B800974C42 /* CustomKeyboardExample */ = {
117 | isa = PBXNativeTarget;
118 | buildConfigurationList = 6B9CDF2B201789B800974C42 /* Build configuration list for PBXNativeTarget "CustomKeyboardExample" */;
119 | buildPhases = (
120 | 6B9CDF15201789B800974C42 /* Sources */,
121 | 6B9CDF16201789B800974C42 /* Frameworks */,
122 | 6B9CDF17201789B800974C42 /* Resources */,
123 | );
124 | buildRules = (
125 | );
126 | dependencies = (
127 | );
128 | name = CustomKeyboardExample;
129 | productName = CustomKeyboardExample;
130 | productReference = 6B9CDF19201789B800974C42 /* CustomKeyboardExample.app */;
131 | productType = "com.apple.product-type.application";
132 | };
133 | /* End PBXNativeTarget section */
134 |
135 | /* Begin PBXProject section */
136 | 6B9CDF11201789B800974C42 /* Project object */ = {
137 | isa = PBXProject;
138 | attributes = {
139 | LastSwiftUpdateCheck = 0920;
140 | LastUpgradeCheck = 1020;
141 | ORGANIZATIONNAME = LC;
142 | TargetAttributes = {
143 | 6B9CDF18201789B800974C42 = {
144 | CreatedOnToolsVersion = 9.2;
145 | ProvisioningStyle = Automatic;
146 | };
147 | };
148 | };
149 | buildConfigurationList = 6B9CDF14201789B800974C42 /* Build configuration list for PBXProject "CustomKeyboardExample" */;
150 | compatibilityVersion = "Xcode 8.0";
151 | developmentRegion = en;
152 | hasScannedForEncodings = 0;
153 | knownRegions = (
154 | en,
155 | Base,
156 | );
157 | mainGroup = 6B9CDF10201789B800974C42;
158 | productRefGroup = 6B9CDF1A201789B800974C42 /* Products */;
159 | projectDirPath = "";
160 | projectRoot = "";
161 | targets = (
162 | 6B9CDF18201789B800974C42 /* CustomKeyboardExample */,
163 | );
164 | };
165 | /* End PBXProject section */
166 |
167 | /* Begin PBXResourcesBuildPhase section */
168 | 6B9CDF17201789B800974C42 /* Resources */ = {
169 | isa = PBXResourcesBuildPhase;
170 | buildActionMask = 2147483647;
171 | files = (
172 | 6B182C0B227C144500643783 /* Keyboard_Backspace@3x.png in Resources */,
173 | 6B9CDF27201789B800974C42 /* LaunchScreen.storyboard in Resources */,
174 | 6B182C0E227C144500643783 /* Keyboard_DismissKey@3x.png in Resources */,
175 | 6B182C09227C144500643783 /* CustomKeyboard.bundle in Resources */,
176 | 6B182C0A227C144500643783 /* Keyboard_Backspace@2x.png in Resources */,
177 | 6B182C0D227C144500643783 /* Keyboard_DismissKey@2x.png in Resources */,
178 | 6B182C0C227C144500643783 /* Keyboard_DismissKey.png in Resources */,
179 | 6B9CDF24201789B800974C42 /* Assets.xcassets in Resources */,
180 | 6B9CDF22201789B800974C42 /* Main.storyboard in Resources */,
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | };
184 | /* End PBXResourcesBuildPhase section */
185 |
186 | /* Begin PBXSourcesBuildPhase section */
187 | 6B9CDF15201789B800974C42 /* Sources */ = {
188 | isa = PBXSourcesBuildPhase;
189 | buildActionMask = 2147483647;
190 | files = (
191 | 6B182C08227C144500643783 /* CustomKeyboard.swift in Sources */,
192 | 6B9CDF1F201789B800974C42 /* ViewController.swift in Sources */,
193 | 6B9CDF1D201789B800974C42 /* AppDelegate.swift in Sources */,
194 | );
195 | runOnlyForDeploymentPostprocessing = 0;
196 | };
197 | /* End PBXSourcesBuildPhase section */
198 |
199 | /* Begin PBXVariantGroup section */
200 | 6B9CDF20201789B800974C42 /* Main.storyboard */ = {
201 | isa = PBXVariantGroup;
202 | children = (
203 | 6B9CDF21201789B800974C42 /* Base */,
204 | );
205 | name = Main.storyboard;
206 | sourceTree = "";
207 | };
208 | 6B9CDF25201789B800974C42 /* LaunchScreen.storyboard */ = {
209 | isa = PBXVariantGroup;
210 | children = (
211 | 6B9CDF26201789B800974C42 /* Base */,
212 | );
213 | name = LaunchScreen.storyboard;
214 | sourceTree = "";
215 | };
216 | /* End PBXVariantGroup section */
217 |
218 | /* Begin XCBuildConfiguration section */
219 | 6B9CDF29201789B800974C42 /* Debug */ = {
220 | isa = XCBuildConfiguration;
221 | buildSettings = {
222 | ALWAYS_SEARCH_USER_PATHS = NO;
223 | CLANG_ANALYZER_NONNULL = YES;
224 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
226 | CLANG_CXX_LIBRARY = "libc++";
227 | CLANG_ENABLE_MODULES = YES;
228 | CLANG_ENABLE_OBJC_ARC = YES;
229 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
230 | CLANG_WARN_BOOL_CONVERSION = YES;
231 | CLANG_WARN_COMMA = YES;
232 | CLANG_WARN_CONSTANT_CONVERSION = YES;
233 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
234 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
235 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
236 | CLANG_WARN_EMPTY_BODY = YES;
237 | CLANG_WARN_ENUM_CONVERSION = YES;
238 | CLANG_WARN_INFINITE_RECURSION = YES;
239 | CLANG_WARN_INT_CONVERSION = YES;
240 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
241 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
242 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
245 | CLANG_WARN_STRICT_PROTOTYPES = YES;
246 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
248 | CLANG_WARN_UNREACHABLE_CODE = YES;
249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
250 | CODE_SIGN_IDENTITY = "iPhone Developer";
251 | COPY_PHASE_STRIP = NO;
252 | DEBUG_INFORMATION_FORMAT = dwarf;
253 | ENABLE_STRICT_OBJC_MSGSEND = YES;
254 | ENABLE_TESTABILITY = YES;
255 | GCC_C_LANGUAGE_STANDARD = gnu11;
256 | GCC_DYNAMIC_NO_PIC = NO;
257 | GCC_NO_COMMON_BLOCKS = YES;
258 | GCC_OPTIMIZATION_LEVEL = 0;
259 | GCC_PREPROCESSOR_DEFINITIONS = (
260 | "DEBUG=1",
261 | "$(inherited)",
262 | );
263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
265 | GCC_WARN_UNDECLARED_SELECTOR = YES;
266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
267 | GCC_WARN_UNUSED_FUNCTION = YES;
268 | GCC_WARN_UNUSED_VARIABLE = YES;
269 | IPHONEOS_DEPLOYMENT_TARGET = 11.2;
270 | MTL_ENABLE_DEBUG_INFO = YES;
271 | ONLY_ACTIVE_ARCH = YES;
272 | SDKROOT = iphoneos;
273 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
274 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
275 | SWIFT_VERSION = 5.0;
276 | };
277 | name = Debug;
278 | };
279 | 6B9CDF2A201789B800974C42 /* Release */ = {
280 | isa = XCBuildConfiguration;
281 | buildSettings = {
282 | ALWAYS_SEARCH_USER_PATHS = NO;
283 | CLANG_ANALYZER_NONNULL = YES;
284 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
285 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
286 | CLANG_CXX_LIBRARY = "libc++";
287 | CLANG_ENABLE_MODULES = YES;
288 | CLANG_ENABLE_OBJC_ARC = YES;
289 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
290 | CLANG_WARN_BOOL_CONVERSION = YES;
291 | CLANG_WARN_COMMA = YES;
292 | CLANG_WARN_CONSTANT_CONVERSION = YES;
293 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
294 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
295 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
296 | CLANG_WARN_EMPTY_BODY = YES;
297 | CLANG_WARN_ENUM_CONVERSION = YES;
298 | CLANG_WARN_INFINITE_RECURSION = YES;
299 | CLANG_WARN_INT_CONVERSION = YES;
300 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
301 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
302 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
303 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
304 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
305 | CLANG_WARN_STRICT_PROTOTYPES = YES;
306 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
307 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
308 | CLANG_WARN_UNREACHABLE_CODE = YES;
309 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
310 | CODE_SIGN_IDENTITY = "iPhone Developer";
311 | COPY_PHASE_STRIP = NO;
312 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
313 | ENABLE_NS_ASSERTIONS = NO;
314 | ENABLE_STRICT_OBJC_MSGSEND = YES;
315 | GCC_C_LANGUAGE_STANDARD = gnu11;
316 | GCC_NO_COMMON_BLOCKS = YES;
317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
319 | GCC_WARN_UNDECLARED_SELECTOR = YES;
320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
321 | GCC_WARN_UNUSED_FUNCTION = YES;
322 | GCC_WARN_UNUSED_VARIABLE = YES;
323 | IPHONEOS_DEPLOYMENT_TARGET = 11.2;
324 | MTL_ENABLE_DEBUG_INFO = NO;
325 | SDKROOT = iphoneos;
326 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
327 | SWIFT_VERSION = 5.0;
328 | VALIDATE_PRODUCT = YES;
329 | };
330 | name = Release;
331 | };
332 | 6B9CDF2C201789B800974C42 /* Debug */ = {
333 | isa = XCBuildConfiguration;
334 | buildSettings = {
335 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
336 | CODE_SIGN_STYLE = Automatic;
337 | DEVELOPMENT_TEAM = "";
338 | INFOPLIST_FILE = CustomKeyboardExample/Info.plist;
339 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
340 | PRODUCT_BUNDLE_IDENTIFIER = com.LC.CustomKeyboardExample;
341 | PRODUCT_NAME = "$(TARGET_NAME)";
342 | SWIFT_VERSION = 5.0;
343 | TARGETED_DEVICE_FAMILY = "1,2";
344 | };
345 | name = Debug;
346 | };
347 | 6B9CDF2D201789B800974C42 /* Release */ = {
348 | isa = XCBuildConfiguration;
349 | buildSettings = {
350 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
351 | CODE_SIGN_STYLE = Automatic;
352 | DEVELOPMENT_TEAM = "";
353 | INFOPLIST_FILE = CustomKeyboardExample/Info.plist;
354 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
355 | PRODUCT_BUNDLE_IDENTIFIER = com.LC.CustomKeyboardExample;
356 | PRODUCT_NAME = "$(TARGET_NAME)";
357 | SWIFT_VERSION = 5.0;
358 | TARGETED_DEVICE_FAMILY = "1,2";
359 | };
360 | name = Release;
361 | };
362 | /* End XCBuildConfiguration section */
363 |
364 | /* Begin XCConfigurationList section */
365 | 6B9CDF14201789B800974C42 /* Build configuration list for PBXProject "CustomKeyboardExample" */ = {
366 | isa = XCConfigurationList;
367 | buildConfigurations = (
368 | 6B9CDF29201789B800974C42 /* Debug */,
369 | 6B9CDF2A201789B800974C42 /* Release */,
370 | );
371 | defaultConfigurationIsVisible = 0;
372 | defaultConfigurationName = Release;
373 | };
374 | 6B9CDF2B201789B800974C42 /* Build configuration list for PBXNativeTarget "CustomKeyboardExample" */ = {
375 | isa = XCConfigurationList;
376 | buildConfigurations = (
377 | 6B9CDF2C201789B800974C42 /* Debug */,
378 | 6B9CDF2D201789B800974C42 /* Release */,
379 | );
380 | defaultConfigurationIsVisible = 0;
381 | defaultConfigurationName = Release;
382 | };
383 | /* End XCConfigurationList section */
384 | };
385 | rootObject = 6B9CDF11201789B800974C42 /* Project object */;
386 | }
387 |
--------------------------------------------------------------------------------
/CustomKeyboard/Classes/CustomKeyboard.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CustomKeyboard.swift
3 | // CustomKeyboard
4 | //
5 | // Created by Liu Chuan on 2017/12/26.
6 | // Copyright © 2017年 LC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | /// 屏幕的宽度
12 | let screenWith = UIScreen.main.bounds.size.width
13 | /// 默认完成按钮颜色
14 | public let defaultDoneColor = UIColor(red:0.45, green:0.69, blue:0.95, alpha:1.00)
15 |
16 | /// 键盘样式
17 | ///
18 | /// - idcard: 身份证类型
19 | /// - number: 数字类型
20 | public enum KeyboardStyle {
21 |
22 | /// 身份证类型
23 | case idcard
24 | /// 数字
25 | case number
26 | }
27 |
28 | // 遵守 UITextFieldDelegate 协议
29 | /// 自定义键盘
30 | open class CustomKeyboard: UIInputView, UITextFieldDelegate, UIGestureRecognizerDelegate {
31 |
32 | // MARK: - 属性
33 | // 存储属性
34 | public static let `default` = CustomKeyboard(frame: CGRect(x: 0, y: 0, width: screenWith, height: 300), inputViewStyle: .keyboard)
35 |
36 | /// 文本输入框
37 | private var textFields = [UITextField]()
38 |
39 | /// 父视图
40 | private var superView: UIView?
41 |
42 | /// 按钮的个数
43 | private let buttonsCount: Int = 14
44 |
45 | /// 按钮数组
46 | fileprivate var buttions: [UIButton] = []
47 |
48 | /// 按钮文字
49 | fileprivate lazy var titles = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
50 |
51 | /// 键盘样式
52 | public var keyboardStyle = KeyboardStyle.idcard {
53 | didSet { // 监听 `style` 数值的改变, 从而设置数字键盘的样式
54 | setDigitButton(keyboardStyle)
55 | }
56 | }
57 |
58 | /// 是否高亮
59 | public var whetherHighlight = false {
60 | didSet { // 监听 `whetherHighlight` 数值的改变, 从而设置按钮高亮状态
61 | highlight(heghlight: whetherHighlight)
62 | }
63 | }
64 |
65 | /// 是否开启键盘
66 | public var isEnableKeyboard: Bool = false {
67 | didSet {
68 | if isEnableKeyboard {
69 | // 注册键盘通知
70 | /**
71 | *参数一:注册观察者对象,参数不能为空
72 | *参数二:收到通知执行的方法,可以带参
73 | *参数三:通知的名字
74 | *参数四:收到指定对象的通知,没有指定具体对象就写nil
75 | */
76 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
77 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
78 | }else {
79 | NotificationCenter.default.removeObserver(self)
80 | }
81 | }
82 | }
83 |
84 | // MARK: - 方法
85 |
86 | /// 自定义完成按钮
87 | ///
88 | /// - Parameters:
89 | /// - title: 标题
90 | /// - titleColor: 标题颜色
91 | /// - theme: 主题
92 | /// - target: 目标控制器
93 | /// - callback: 回调
94 | public func customDoneButton(title: String, titleColor: UIColor = UIColor.white, theme: UIColor = defaultDoneColor, target: UIViewController? = nil, callback: Selector? = nil) {
95 |
96 | setDoneButton(title, titleColor: titleColor, theme: theme, target: target, callback: callback)
97 | }
98 |
99 | /*
100 | 指定构造器: 必须调用它直接父类的指定构造器方法.
101 | 便利构造器: 必须调用同一个类中定义的其它初始化方法.
102 | 便利构造器: 在最后必须调用一个指定构造器.
103 | */
104 | /// 便利构造器
105 | ///
106 | /// - Parameters:
107 | /// - view: 视图
108 | /// - field: 文本输入框
109 | public convenience init(_ view: UIView, field: UITextField? = nil) {
110 |
111 | self.init(frame: CGRect.zero, inputViewStyle: .keyboard)
112 | backgroundColor = .white
113 | addKeyboard(view, field: field)
114 | }
115 |
116 |
117 | /// 初始化方法
118 | ///
119 | /// - Parameters:
120 | /// - frame: 尺寸
121 | /// - inputViewStyle: 输入视图样式
122 | public override init(frame: CGRect, inputViewStyle: UIInputView.Style) {
123 | super.init(frame: frame, inputViewStyle: inputViewStyle)
124 | }
125 |
126 | public required init?(coder _: NSCoder) {
127 | fatalError("init(coder:) has not been implemented")
128 | }
129 |
130 | /***** 布局视图的时候调用 *****/
131 | open override func layoutSubviews() {
132 | super.layoutSubviews()
133 |
134 | /// 纵列数
135 | let columnsNum = 4
136 |
137 | /// 一个按钮的宽度
138 | let btnWidth = frame.width / CGFloat(columnsNum)
139 |
140 | /// 一个按钮的高度
141 | let btnHeight = frame.height / CGFloat(columnsNum)
142 |
143 | /***循环布局12个按钮***/
144 | for i in 0...11 {
145 | let view = viewWithTag(i + 1)
146 | view?.frame.origin.x = btnWidth * CGFloat((i) % 3) //3个按钮以换行
147 | view?.frame.origin.y = btnHeight * CGFloat((i) / 3)
148 | view?.frame.size.width = btnWidth
149 | view?.frame.size.height = btnHeight
150 | }
151 | /**** 右边: 删除\确定按钮 ****/
152 | // 因为上文button的tag值加1, 所以获取tag值需要加1
153 | viewWithTag(12 + 1)?.frame = CGRect(x: btnWidth * 3, y: 0, width: btnWidth, height: btnHeight * 2)
154 | viewWithTag(13 + 1)?.frame = CGRect(x: btnWidth * 3, y: btnHeight * 2, width: btnWidth, height: btnHeight * 2)
155 | }
156 |
157 | /***** 绘制界面: 按钮的分割线 *****/
158 | // 调用情况: 1.UIView初始化后自动调用; 2.调用setNeedsDisplay方法时会自动调用)
159 | open override func draw(_ rect: CGRect) {
160 |
161 | /// 纵列数
162 | let columnsNum = 4
163 |
164 | /// 一个按钮的宽度
165 | let btnWidth = frame.width / CGFloat(columnsNum)
166 |
167 | /// 一个按钮的高度
168 | let btnHeight = frame.height / CGFloat(columnsNum)
169 |
170 | // 创建一个贝塞尔路径
171 | let bezierPath = UIBezierPath()
172 |
173 | for i in 0 ... 3 { // 4条横线
174 | //开始绘制
175 | bezierPath.move(to: CGPoint(x: 0, y: btnHeight * CGFloat(i)))
176 | bezierPath.addLine(to: CGPoint(x: frame.width, y: btnHeight * CGFloat(i)))
177 | }
178 | for i in 1 ... 3 { // 3条竖线
179 | bezierPath.move(to: CGPoint(x: btnWidth * CGFloat(i), y: 0))
180 | bezierPath.addLine(to: CGPoint(x: btnWidth * CGFloat(i), y: frame.height))
181 | }
182 | UIColor.lightGray.setStroke()
183 | bezierPath.lineWidth = 1
184 | bezierPath.stroke()
185 | }
186 |
187 | /// 设置完成按钮
188 | ///
189 | /// - Parameters:
190 | /// - title: 标题
191 | /// - titleColor: 标题颜色
192 | /// - theme: 主题
193 | /// - target: 目标控制器
194 | /// - callback: 回调
195 | private func setDoneButton(_ title: String, titleColor: UIColor, theme: UIColor, target: UIViewController?, callback: Selector?) {
196 | // 通过tag值获取done按钮
197 | guard let itemButton = findButton(by: 13 + 1) else {
198 | fatalError("not found the button with the tag")
199 | }
200 | if let selector = callback, let target = target {
201 | itemButton.addTarget(target, action: selector, for: .touchUpInside)
202 | }
203 | itemButton.titleLabel?.font = UIFont.systemFont(ofSize: 17)
204 | itemButton.setTitle(title, for: .normal)
205 | itemButton.backgroundColor = theme
206 | itemButton.setTitleColor(titleColor, for: .normal)
207 | }
208 |
209 | /// 添加键盘视图
210 | ///
211 | /// - Parameters:
212 | /// - view: 视图
213 | /// - field: 文本输入框
214 | private func addKeyboard(_ view: UIView, field: UITextField? = nil) {
215 | superView = view
216 | customSubview()
217 |
218 | guard let textField = field else {
219 | for view in (superView?.subviews)! {
220 | guard view.isKind(of: UITextField.self) else { return }
221 | let textField = view as! UITextField
222 | textField.delegate = self
223 | textField.inputView = self
224 | textFields.append(textField)
225 | }
226 | return
227 | }
228 | textFields.append(textField)
229 | textField.inputView = self
230 | textField.delegate = self
231 | }
232 |
233 |
234 | /// 自定义视图
235 | private func customSubview() {
236 |
237 | /// 退格键\删除键 图片视图
238 | var backSpace: UIImage?
239 |
240 | /// 消失图片视图
241 | var dismiss: UIImage?
242 |
243 | // 获取指向类对象的引用,只需使用 ClassName.self
244 | let podBundle = Bundle(for: CustomKeyboard.self)
245 |
246 | // 获取当前类的文件路径
247 | guard let bundleURL = podBundle.url(forResource: "CustomKeyboard", withExtension: "bundle") else {
248 | backSpace = UIImage(named: "Keyboard_Backspace")
249 | dismiss = UIImage(named: "Keyboard_DismissKey")
250 | return
251 | }
252 | guard let bundle = Bundle(url: bundleURL) else {
253 | backSpace = UIImage(named: "Keyboard_Backspace")
254 | dismiss = UIImage(named: "Keyboard_DismissKey")
255 | return
256 | }
257 | // 设置图片
258 | backSpace = UIImage(named: "Keyboard_Backspace", in: bundle, compatibleWith: nil)
259 | dismiss = UIImage(named: "Keyboard_DismissKey", in: bundle, compatibleWith: nil)
260 |
261 | /* 创建键盘视图上所有的按钮 */
262 | for idx in 0 ..< buttonsCount {
263 | let button = UIButton()
264 | button.titleLabel?.font = UIFont.systemFont(ofSize: 28)
265 | button.setTitleColor(UIColor.black, for: .normal)
266 |
267 | switch idx { // tag值
268 | case 9: //包含0, 所以当前是第10个按钮
269 | button.setTitle("", for: .normal)
270 | button.setImage(dismiss, for: .normal)
271 | case 10: // 0
272 | button.setTitle("0", for: .normal)
273 | buttions.append(button)
274 | case 11: // 小数点
275 | button.setTitle("X", for: .normal)
276 | case 12: // 退格键
277 | button.setTitle("", for: .normal)
278 | button.setImage(backSpace, for: .normal)
279 | button.backgroundColor = .white
280 | case 13: // 完成按钮
281 | button.titleLabel?.font = UIFont.systemFont(ofSize: 17)
282 | button.backgroundColor = defaultDoneColor
283 | button.setTitleColor(UIColor.white, for: .normal)
284 | button.setBackgroundImage(nil, for: .normal)
285 | button.setBackgroundImage(nil, for: .highlighted)
286 | button.setTitle(LocalizedString("Done"), for: .normal)
287 | default: // 数字按钮
288 | button.setTitle("\(idx + 1)", for: .normal)
289 | buttions.append(button)
290 | }
291 | button.addTarget(self, action: #selector(tap), for: .touchUpInside)
292 | addSubview(button)
293 | button.tag = idx + 1
294 | }
295 | }
296 |
297 | /// 键盘视图按钮点击事件
298 | ///
299 | /// - Parameter sender: 按钮
300 | @objc func tap(_ sender: UIButton) {
301 | // 获取按钮的当前文字
302 | guard let text = sender.currentTitle else {
303 | fatalError("not found the sender's currentTitle")
304 | }
305 | // 因为上文button的tag值加1, 所以值改变了
306 | switch sender.tag {
307 | case 12: // 小数点
308 | handlePoint(btn: sender)
309 | case 12 + 1: // 删除
310 | handleDelete(button: sender)
311 | case 13 + 1, 9 + 1: // 隐藏键盘\确定键,辞去第一响应者
312 | firstResponder()?.resignFirstResponder()
313 | default: // 其他按钮文本框插入当前输入文本
314 | firstResponder()?.insertText(text)
315 | }
316 | /*
317 | 播放输入点击.
318 | 想要在点击自定义输入或键盘附加视图的键时: 播放输入点击音,首先要确认该视图采用了UIInputViewAudioFeedback协议。
319 | 然后,为每个点击提供你想要的点击声音,调用UIDevice类的playInputClick方法
320 | */
321 | UIDevice.current.playInputClick()
322 | }
323 |
324 | /// 处理小数点
325 | ///
326 | /// - Parameter btn: 按钮
327 | private func handlePoint(btn: UIButton) {
328 |
329 | // 获取按钮的当前文字
330 | guard let text = btn.currentTitle else { return }
331 |
332 | // 获取文本输入框的文字
333 | guard let str = firstResponder()?.text else { return }
334 | // 是否包含字符 '.'
335 | let subStr = str.contains(".")
336 |
337 | if subStr {
338 | print("小数点已存在....")
339 | }else {
340 | firstResponder()?.insertText(text)
341 | }
342 | }
343 |
344 | /// 处理删除
345 | private func handleDelete(button: UIButton) {
346 |
347 | // 单击删除
348 | firstResponder()?.deleteBackward()
349 |
350 | /// 创建长按手势
351 | let longPress = UILongPressGestureRecognizer(target: self, action: #selector(deleteLongPressed))
352 | longPress.delegate = self
353 |
354 | // 设置最低长按时长 ( 以秒为单位 )
355 | longPress.minimumPressDuration = 0.5
356 |
357 | // 添加长按手势
358 | button.addGestureRecognizer(longPress)
359 | }
360 |
361 | /// 删除按钮长按事件
362 | ///
363 | /// - Parameter sender: 长按手势
364 | @objc private func deleteLongPressed(_ sender: UILongPressGestureRecognizer) {
365 |
366 | guard sender.state == .began else {
367 | print("长按响应结束")
368 | return
369 | }
370 | print("长按响应开始")
371 | /* 根据文本输入框的文字的个数, 多次循环删除 */
372 | for _ in 0 ... (firstResponder()?.text?.count)! {
373 | firstResponder()?.deleteBackward()
374 | }
375 | }
376 |
377 | /// 高亮状态
378 | ///
379 | /// - Parameter heghlight: 是否高亮
380 | private func highlight(heghlight: Bool) {
381 |
382 | print(subviews.count)
383 |
384 | /// 获取当前视图的所有子视图的个数
385 | let subviewCount = subviews.count
386 |
387 | /// 获取当前视图的所有按钮的个数
388 | let subviewBtnCout = subviewCount - 2
389 |
390 | for i in 2 ... subviewBtnCout {
391 | // 获取按钮
392 | guard let button = subviews[i] as? UIButton else { return }
393 | // 如何是确定按钮就直接返回
394 | if button.tag == 13 + 1 { return }
395 | if heghlight {
396 | button.setBackgroundImage(UIImage.dk_image(with: .clear), for: .normal)
397 | button.setBackgroundImage(UIImage.dk_image(with: .lightGray), for: .highlighted)
398 | }else {
399 | button.setBackgroundImage(UIImage.dk_image(with: .clear), for: .normal)
400 | button.setBackgroundImage(UIImage.dk_image(with: .clear), for: .highlighted)
401 | }
402 | }
403 | }
404 |
405 | /// 设置数字按钮的样式
406 | ///
407 | /// - Parameter style: 样式
408 | private func setDigitButton(_ style: KeyboardStyle) {
409 | guard let button = findButton(by: 12) else {
410 | fatalError("not found the button with the tag")
411 | }
412 | switch keyboardStyle {
413 | case .idcard:
414 | button.setTitle("X", for: .normal)
415 | case .number:
416 | let locale = Locale.current
417 | // 返回地区的十进制分隔符。例如,对于“en_US”,返回“.”
418 | let decimalSeparator = locale.decimalSeparator! as String
419 | button.setTitle(decimalSeparator, for: .normal)
420 | }
421 | }
422 |
423 | /// 第一响应者
424 | ///
425 | /// - Returns: 文本输入框
426 | private func firstResponder() -> UITextField? {
427 | var firstResponder: UITextField?
428 | for field in textFields {
429 | if field.isFirstResponder {
430 | firstResponder = field
431 | }
432 | }
433 | return firstResponder
434 | }
435 |
436 | /// 通过按钮的 tag 值,获取按钮
437 | ///
438 | /// - Parameter tag: tag 值
439 | /// - Returns: 按钮
440 | private func findButton(by tag: Int) -> UIButton? {
441 |
442 | for button in subviews {
443 | if button.tag == tag {
444 | return button as? UIButton
445 | }
446 | }
447 | return nil
448 | }
449 |
450 | /// 调用Bundle的localizedString去查找指定( 调用者 )下的key并返回值
451 | ///
452 | /// - Parameter key: 调用者的key
453 | /// - Returns: 字符串
454 | private func LocalizedString(_ key: String) -> String {
455 | return (Bundle(identifier: "com.apple.UIKit")?.localizedString(forKey: key, value: nil, table: nil))!
456 | }
457 |
458 | /// 键盘即将显示 (弹起)
459 | ///
460 | /// - Parameter notification: 通知
461 | @objc fileprivate func keyboardWillShow(_ notification: NSNotification) {
462 | print("成为第一响应者 (弹起键盘)")
463 | }
464 |
465 | /// 键盘即将隐藏 (收起)
466 | ///
467 | /// - Parameter notification: 通知
468 | @objc fileprivate func keyboardWillHide(_ notification: NSNotification) {
469 | print("辞去第一响应者 (收起键盘)")
470 | }
471 |
472 | }
473 | // MARK: - 扩展 UIImage
474 | extension UIImage {
475 |
476 | /// 利用颜色绘制成新的图片
477 | ///
478 | /// - Parameters:
479 | /// - color: 颜色
480 | /// - size: 尺寸
481 | /// - Returns: UIImage
482 | fileprivate class func dk_image(with color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
483 |
484 | // 开启图形上下文
485 | UIGraphicsBeginImageContext(size)
486 | // 设置颜色
487 | color.set()
488 |
489 | //用下面混合模式,以渐变.效果为歌词逐字依次变为绿色(基于progress的递增)
490 | //UIRectFillUsingBlendMode(fillRect, kCGBlendModeSourceIn)
491 | // 直接绘图
492 | UIRectFill(CGRect(origin: CGPoint.zero, size: size))
493 |
494 | let image = UIGraphicsGetImageFromCurrentImageContext()!
495 | // 关闭图形上下文
496 | UIGraphicsEndImageContext()
497 | return image
498 | }
499 | }
500 |
501 | // MARK: - UIInputViewAudioFeedback
502 | /* 播放输入点击
503 | 当用户点击自定义输入视图和键盘附加视图的时候,你可以播放标准的系统键盘点击音。首先,在你的输入视图中采用UIInputViewAudioFeedback协议。然后,当响应该视图的键盘点击的时候调用playInputClick方法。
504 | */
505 | extension CustomKeyboard: UIInputViewAudioFeedback {
506 | open var enableInputClicksWhenVisible: Bool {
507 | return true
508 | }
509 | }
510 |
--------------------------------------------------------------------------------