├── .gitignore
├── .swift-version
├── KeyboardMan.podspec
├── KeyboardMan
├── Info.plist
├── KeyboardMan.h
└── KeyboardMan.swift
├── LICENSE
├── Messages.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcshareddata
│ └── xcschemes
│ └── KeyboardMan.xcscheme
├── Messages
├── AppDelegate.swift
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
└── ViewController.swift
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # OS X
21 | .DS_Store
22 |
--------------------------------------------------------------------------------
/.swift-version:
--------------------------------------------------------------------------------
1 | 4.2
2 |
--------------------------------------------------------------------------------
/KeyboardMan.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 |
3 | s.name = "KeyboardMan"
4 | s.version = "1.2.3"
5 | s.summary = "KeyboardMan helps you do keyboard animation."
6 |
7 | s.description = <<-DESC
8 | We may need keyboard infomation from keyboard notification to do animation.
9 | However, the approach is complicated and easy to make mistakes.
10 | But KeyboardMan will make it simple & easy.
11 | DESC
12 |
13 | s.homepage = "https://github.com/nixzhu/KeyboardMan"
14 |
15 | s.license = { :type => "MIT", :file => "LICENSE" }
16 |
17 | s.authors = { "nixzhu" => "zhuhongxu@gmail.com" }
18 | s.social_media_url = "https://twitter.com/nixzhu"
19 |
20 | s.ios.deployment_target = "8.0"
21 |
22 | s.source = { :git => "https://github.com/nixzhu/KeyboardMan.git", :tag => s.version }
23 | s.source_files = "KeyboardMan/*.swift"
24 | s.requires_arc = true
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/KeyboardMan/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.2.3
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/KeyboardMan/KeyboardMan.h:
--------------------------------------------------------------------------------
1 | //
2 | // KeyboardMan.h
3 | // KeyboardMan
4 | //
5 | // Created by NIX on 15/7/25.
6 | // Copyright (c) 2015年 nixWork. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for KeyboardMan.
12 | FOUNDATION_EXPORT double KeyboardManVersionNumber;
13 |
14 | //! Project version string for KeyboardMan.
15 | FOUNDATION_EXPORT const unsigned char KeyboardManVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/KeyboardMan/KeyboardMan.swift:
--------------------------------------------------------------------------------
1 | //
2 | // KeyboardMan.swift
3 | // Messages
4 | //
5 | // Created by NIX on 15/7/25.
6 | // Copyright (c) 2015年 nixWork. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | final public class KeyboardMan {
12 |
13 | var keyboardObserver: NotificationCenter? {
14 | didSet {
15 | oldValue?.removeObserver(self)
16 | keyboardObserver?.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
17 | keyboardObserver?.addObserver(self, selector: #selector(keyboardWillChangeFrame(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
18 | keyboardObserver?.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
19 | keyboardObserver?.addObserver(self, selector: #selector(keyboardDidHide(_:)), name: UIResponder.keyboardDidHideNotification, object: nil)
20 | }
21 | }
22 |
23 | public var keyboardObserveEnabled = false {
24 | willSet {
25 | if newValue != keyboardObserveEnabled {
26 | keyboardObserver = newValue ? .default : nil
27 | }
28 | }
29 | }
30 |
31 | deinit {
32 | // willSet and didSet are not called when deinit, so...
33 | NotificationCenter.default.removeObserver(self)
34 | }
35 |
36 | public init() {
37 | }
38 |
39 | public struct KeyboardInfo {
40 | public let animationDuration: TimeInterval
41 | public let animationCurve: UInt
42 | public let frameBegin: CGRect
43 | public let frameEnd: CGRect
44 | public var height: CGFloat {
45 | return frameEnd.height
46 | }
47 | public let heightIncrement: CGFloat
48 | public enum Action {
49 | case show
50 | case hide
51 | }
52 | public let action: Action
53 | let isSameAction: Bool
54 | }
55 |
56 | public private(set) var appearPostIndex = 0
57 |
58 | public private(set) var keyboardInfo: KeyboardInfo? {
59 | didSet {
60 | guard UIApplication.isNotInBackground else { return }
61 | guard let info = keyboardInfo else { return }
62 | if !info.isSameAction || info.heightIncrement != 0 {
63 | // do convenient animation
64 | let duration = info.animationDuration
65 | let curve = info.animationCurve
66 | let options = UIView.AnimationOptions(rawValue: curve << 16 | UIView.AnimationOptions.beginFromCurrentState.rawValue | UIView.AnimationOptions.allowUserInteraction.rawValue)
67 | UIView.animate(withDuration: duration, delay: 0, options: options, animations: { [weak self] in
68 | guard let self = self else { return }
69 | switch info.action {
70 | case .show:
71 | self.animateWhenKeyboardAppear?(self.appearPostIndex, info.height, info.heightIncrement)
72 | self.appearPostIndex += 1
73 | case .hide:
74 | self.animateWhenKeyboardDisappear?(info.height)
75 | self.appearPostIndex = 0
76 | }
77 | }, completion: nil)
78 | // post full info
79 | postKeyboardInfo?(self, info)
80 | }
81 | }
82 | }
83 |
84 | public var animateWhenKeyboardAppear: ((_ appearPostIndex: Int, _ keyboardHeight: CGFloat, _ keyboardHeightIncrement: CGFloat) -> Void)? {
85 | didSet {
86 | keyboardObserveEnabled = true
87 | }
88 | }
89 |
90 | public var animateWhenKeyboardDisappear: ((_ keyboardHeight: CGFloat) -> Void)? {
91 | didSet {
92 | keyboardObserveEnabled = true
93 | }
94 | }
95 |
96 | public var postKeyboardInfo: ((_ keyboardMan: KeyboardMan, _ keyboardInfo: KeyboardInfo) -> Void)? {
97 | didSet {
98 | keyboardObserveEnabled = true
99 | }
100 | }
101 |
102 | // MARK: - Actions
103 |
104 | private func handleKeyboard(_ notification: Notification, _ action: KeyboardInfo.Action) {
105 | guard let userInfo = notification.userInfo else { return }
106 | let animationDuration: TimeInterval = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
107 | let animationCurve = (userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! NSNumber).uintValue
108 | let frameBegin = (userInfo[UIResponder.keyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
109 | let frameEnd = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
110 | let currentHeight = frameEnd.height
111 | let previousHeight = keyboardInfo?.height ?? 0
112 | let heightIncrement = currentHeight - previousHeight
113 | let isSameAction: Bool
114 | if let previousAction = keyboardInfo?.action {
115 | isSameAction = (action == previousAction)
116 | } else {
117 | isSameAction = false
118 | }
119 | keyboardInfo = KeyboardInfo(
120 | animationDuration: animationDuration,
121 | animationCurve: animationCurve,
122 | frameBegin: frameBegin,
123 | frameEnd: frameEnd,
124 | heightIncrement: heightIncrement,
125 | action: action,
126 | isSameAction: isSameAction
127 | )
128 | }
129 |
130 | @objc private func keyboardWillShow(_ notification: Notification) {
131 | guard UIApplication.isNotInBackground else { return }
132 | handleKeyboard(notification, .show)
133 | }
134 |
135 | @objc private func keyboardWillChangeFrame(_ notification: Notification) {
136 | guard UIApplication.isNotInBackground else { return }
137 | if let keyboardInfo = keyboardInfo, keyboardInfo.action == .show {
138 | handleKeyboard(notification, .show)
139 | }
140 | }
141 |
142 | @objc private func keyboardWillHide(_ notification: Notification) {
143 | guard UIApplication.isNotInBackground else { return }
144 | handleKeyboard(notification, .hide)
145 | }
146 |
147 | @objc private func keyboardDidHide(_ notification: Notification) {
148 | guard UIApplication.isNotInBackground else { return }
149 | keyboardInfo = nil
150 | }
151 | }
152 |
153 | extension UIApplication {
154 | // Return UIApplication.shared in an app target, `nil` in an app extension target.
155 | private static let sharedOrNil: UIApplication? = {
156 | let selector = NSSelectorFromString("sharedApplication")
157 | guard UIApplication.responds(to: selector) else { return nil }
158 | let application = UIApplication.perform(selector).takeUnretainedValue() as? UIApplication
159 | // The appDelegate is nil, normally it is in app extension context.
160 | guard let _ = application?.delegate else { return nil }
161 | return application
162 | }()
163 |
164 | static var isNotInBackground: Bool {
165 | return sharedOrNil?.applicationState != .background
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2018 nixzhu
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 |
--------------------------------------------------------------------------------
/Messages.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 50FA99FD1B63AEF0009BF2A0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FA99FC1B63AEF0009BF2A0 /* AppDelegate.swift */; };
11 | 50FA99FF1B63AEF0009BF2A0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FA99FE1B63AEF0009BF2A0 /* ViewController.swift */; };
12 | 50FA9A021B63AEF0009BF2A0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50FA9A001B63AEF0009BF2A0 /* Main.storyboard */; };
13 | 50FA9A041B63AEF0009BF2A0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50FA9A031B63AEF0009BF2A0 /* Images.xcassets */; };
14 | 50FA9A071B63AEF0009BF2A0 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50FA9A051B63AEF0009BF2A0 /* LaunchScreen.xib */; };
15 | 50FA9A261B63AF69009BF2A0 /* KeyboardMan.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FA9A251B63AF69009BF2A0 /* KeyboardMan.h */; settings = {ATTRIBUTES = (Public, ); }; };
16 | 50FA9A381B63AF69009BF2A0 /* KeyboardMan.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50FA9A211B63AF69009BF2A0 /* KeyboardMan.framework */; };
17 | 50FA9A391B63AF69009BF2A0 /* KeyboardMan.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 50FA9A211B63AF69009BF2A0 /* KeyboardMan.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
18 | 50FA9A421B63AFA5009BF2A0 /* KeyboardMan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FA9A411B63AFA4009BF2A0 /* KeyboardMan.swift */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXContainerItemProxy section */
22 | 50FA9A361B63AF69009BF2A0 /* PBXContainerItemProxy */ = {
23 | isa = PBXContainerItemProxy;
24 | containerPortal = 50FA99EF1B63AEF0009BF2A0 /* Project object */;
25 | proxyType = 1;
26 | remoteGlobalIDString = 50FA9A201B63AF69009BF2A0;
27 | remoteInfo = KeyboardMan;
28 | };
29 | /* End PBXContainerItemProxy section */
30 |
31 | /* Begin PBXCopyFilesBuildPhase section */
32 | 50FA9A3F1B63AF69009BF2A0 /* Embed Frameworks */ = {
33 | isa = PBXCopyFilesBuildPhase;
34 | buildActionMask = 2147483647;
35 | dstPath = "";
36 | dstSubfolderSpec = 10;
37 | files = (
38 | 50FA9A391B63AF69009BF2A0 /* KeyboardMan.framework in Embed Frameworks */,
39 | );
40 | name = "Embed Frameworks";
41 | runOnlyForDeploymentPostprocessing = 0;
42 | };
43 | /* End PBXCopyFilesBuildPhase section */
44 |
45 | /* Begin PBXFileReference section */
46 | 50FA99F71B63AEF0009BF2A0 /* Messages.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Messages.app; sourceTree = BUILT_PRODUCTS_DIR; };
47 | 50FA99FB1B63AEF0009BF2A0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
48 | 50FA99FC1B63AEF0009BF2A0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
49 | 50FA99FE1B63AEF0009BF2A0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
50 | 50FA9A011B63AEF0009BF2A0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
51 | 50FA9A031B63AEF0009BF2A0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
52 | 50FA9A061B63AEF0009BF2A0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
53 | 50FA9A211B63AF69009BF2A0 /* KeyboardMan.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = KeyboardMan.framework; sourceTree = BUILT_PRODUCTS_DIR; };
54 | 50FA9A241B63AF69009BF2A0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
55 | 50FA9A251B63AF69009BF2A0 /* KeyboardMan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyboardMan.h; sourceTree = ""; };
56 | 50FA9A411B63AFA4009BF2A0 /* KeyboardMan.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardMan.swift; sourceTree = ""; };
57 | /* End PBXFileReference section */
58 |
59 | /* Begin PBXFrameworksBuildPhase section */
60 | 50FA99F41B63AEF0009BF2A0 /* Frameworks */ = {
61 | isa = PBXFrameworksBuildPhase;
62 | buildActionMask = 2147483647;
63 | files = (
64 | 50FA9A381B63AF69009BF2A0 /* KeyboardMan.framework in Frameworks */,
65 | );
66 | runOnlyForDeploymentPostprocessing = 0;
67 | };
68 | 50FA9A1D1B63AF69009BF2A0 /* Frameworks */ = {
69 | isa = PBXFrameworksBuildPhase;
70 | buildActionMask = 2147483647;
71 | files = (
72 | );
73 | runOnlyForDeploymentPostprocessing = 0;
74 | };
75 | /* End PBXFrameworksBuildPhase section */
76 |
77 | /* Begin PBXGroup section */
78 | 50FA99EE1B63AEF0009BF2A0 = {
79 | isa = PBXGroup;
80 | children = (
81 | 50FA99F91B63AEF0009BF2A0 /* Messages */,
82 | 50FA9A221B63AF69009BF2A0 /* KeyboardMan */,
83 | 50FA99F81B63AEF0009BF2A0 /* Products */,
84 | );
85 | sourceTree = "";
86 | };
87 | 50FA99F81B63AEF0009BF2A0 /* Products */ = {
88 | isa = PBXGroup;
89 | children = (
90 | 50FA99F71B63AEF0009BF2A0 /* Messages.app */,
91 | 50FA9A211B63AF69009BF2A0 /* KeyboardMan.framework */,
92 | );
93 | name = Products;
94 | sourceTree = "";
95 | };
96 | 50FA99F91B63AEF0009BF2A0 /* Messages */ = {
97 | isa = PBXGroup;
98 | children = (
99 | 50FA99FC1B63AEF0009BF2A0 /* AppDelegate.swift */,
100 | 50FA99FE1B63AEF0009BF2A0 /* ViewController.swift */,
101 | 50FA9A001B63AEF0009BF2A0 /* Main.storyboard */,
102 | 50FA9A031B63AEF0009BF2A0 /* Images.xcassets */,
103 | 50FA9A051B63AEF0009BF2A0 /* LaunchScreen.xib */,
104 | 50FA99FA1B63AEF0009BF2A0 /* Supporting Files */,
105 | );
106 | path = Messages;
107 | sourceTree = "";
108 | };
109 | 50FA99FA1B63AEF0009BF2A0 /* Supporting Files */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 50FA99FB1B63AEF0009BF2A0 /* Info.plist */,
113 | );
114 | name = "Supporting Files";
115 | sourceTree = "";
116 | };
117 | 50FA9A221B63AF69009BF2A0 /* KeyboardMan */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 50FA9A251B63AF69009BF2A0 /* KeyboardMan.h */,
121 | 50FA9A411B63AFA4009BF2A0 /* KeyboardMan.swift */,
122 | 50FA9A231B63AF69009BF2A0 /* Supporting Files */,
123 | );
124 | path = KeyboardMan;
125 | sourceTree = "";
126 | };
127 | 50FA9A231B63AF69009BF2A0 /* Supporting Files */ = {
128 | isa = PBXGroup;
129 | children = (
130 | 50FA9A241B63AF69009BF2A0 /* Info.plist */,
131 | );
132 | name = "Supporting Files";
133 | sourceTree = "";
134 | };
135 | /* End PBXGroup section */
136 |
137 | /* Begin PBXHeadersBuildPhase section */
138 | 50FA9A1E1B63AF69009BF2A0 /* Headers */ = {
139 | isa = PBXHeadersBuildPhase;
140 | buildActionMask = 2147483647;
141 | files = (
142 | 50FA9A261B63AF69009BF2A0 /* KeyboardMan.h in Headers */,
143 | );
144 | runOnlyForDeploymentPostprocessing = 0;
145 | };
146 | /* End PBXHeadersBuildPhase section */
147 |
148 | /* Begin PBXNativeTarget section */
149 | 50FA99F61B63AEF0009BF2A0 /* Messages */ = {
150 | isa = PBXNativeTarget;
151 | buildConfigurationList = 50FA9A161B63AEF0009BF2A0 /* Build configuration list for PBXNativeTarget "Messages" */;
152 | buildPhases = (
153 | 50FA99F31B63AEF0009BF2A0 /* Sources */,
154 | 50FA99F41B63AEF0009BF2A0 /* Frameworks */,
155 | 50FA99F51B63AEF0009BF2A0 /* Resources */,
156 | 50FA9A3F1B63AF69009BF2A0 /* Embed Frameworks */,
157 | );
158 | buildRules = (
159 | );
160 | dependencies = (
161 | 50FA9A371B63AF69009BF2A0 /* PBXTargetDependency */,
162 | );
163 | name = Messages;
164 | productName = Messages;
165 | productReference = 50FA99F71B63AEF0009BF2A0 /* Messages.app */;
166 | productType = "com.apple.product-type.application";
167 | };
168 | 50FA9A201B63AF69009BF2A0 /* KeyboardMan */ = {
169 | isa = PBXNativeTarget;
170 | buildConfigurationList = 50FA9A3E1B63AF69009BF2A0 /* Build configuration list for PBXNativeTarget "KeyboardMan" */;
171 | buildPhases = (
172 | 50FA9A1C1B63AF69009BF2A0 /* Sources */,
173 | 50FA9A1D1B63AF69009BF2A0 /* Frameworks */,
174 | 50FA9A1E1B63AF69009BF2A0 /* Headers */,
175 | 50FA9A1F1B63AF69009BF2A0 /* Resources */,
176 | );
177 | buildRules = (
178 | );
179 | dependencies = (
180 | );
181 | name = KeyboardMan;
182 | productName = KeyboardMan;
183 | productReference = 50FA9A211B63AF69009BF2A0 /* KeyboardMan.framework */;
184 | productType = "com.apple.product-type.framework";
185 | };
186 | /* End PBXNativeTarget section */
187 |
188 | /* Begin PBXProject section */
189 | 50FA99EF1B63AEF0009BF2A0 /* Project object */ = {
190 | isa = PBXProject;
191 | attributes = {
192 | LastSwiftMigration = 0700;
193 | LastSwiftUpdateCheck = 0700;
194 | LastUpgradeCheck = 0930;
195 | ORGANIZATIONNAME = nixWork;
196 | TargetAttributes = {
197 | 50FA99F61B63AEF0009BF2A0 = {
198 | CreatedOnToolsVersion = 6.4;
199 | DevelopmentTeam = 8D957V42M6;
200 | LastSwiftMigration = 1000;
201 | };
202 | 50FA9A201B63AF69009BF2A0 = {
203 | CreatedOnToolsVersion = 6.4;
204 | LastSwiftMigration = 1000;
205 | };
206 | };
207 | };
208 | buildConfigurationList = 50FA99F21B63AEF0009BF2A0 /* Build configuration list for PBXProject "Messages" */;
209 | compatibilityVersion = "Xcode 3.2";
210 | developmentRegion = English;
211 | hasScannedForEncodings = 0;
212 | knownRegions = (
213 | en,
214 | Base,
215 | );
216 | mainGroup = 50FA99EE1B63AEF0009BF2A0;
217 | productRefGroup = 50FA99F81B63AEF0009BF2A0 /* Products */;
218 | projectDirPath = "";
219 | projectRoot = "";
220 | targets = (
221 | 50FA99F61B63AEF0009BF2A0 /* Messages */,
222 | 50FA9A201B63AF69009BF2A0 /* KeyboardMan */,
223 | );
224 | };
225 | /* End PBXProject section */
226 |
227 | /* Begin PBXResourcesBuildPhase section */
228 | 50FA99F51B63AEF0009BF2A0 /* Resources */ = {
229 | isa = PBXResourcesBuildPhase;
230 | buildActionMask = 2147483647;
231 | files = (
232 | 50FA9A021B63AEF0009BF2A0 /* Main.storyboard in Resources */,
233 | 50FA9A071B63AEF0009BF2A0 /* LaunchScreen.xib in Resources */,
234 | 50FA9A041B63AEF0009BF2A0 /* Images.xcassets in Resources */,
235 | );
236 | runOnlyForDeploymentPostprocessing = 0;
237 | };
238 | 50FA9A1F1B63AF69009BF2A0 /* Resources */ = {
239 | isa = PBXResourcesBuildPhase;
240 | buildActionMask = 2147483647;
241 | files = (
242 | );
243 | runOnlyForDeploymentPostprocessing = 0;
244 | };
245 | /* End PBXResourcesBuildPhase section */
246 |
247 | /* Begin PBXSourcesBuildPhase section */
248 | 50FA99F31B63AEF0009BF2A0 /* Sources */ = {
249 | isa = PBXSourcesBuildPhase;
250 | buildActionMask = 2147483647;
251 | files = (
252 | 50FA99FF1B63AEF0009BF2A0 /* ViewController.swift in Sources */,
253 | 50FA99FD1B63AEF0009BF2A0 /* AppDelegate.swift in Sources */,
254 | );
255 | runOnlyForDeploymentPostprocessing = 0;
256 | };
257 | 50FA9A1C1B63AF69009BF2A0 /* Sources */ = {
258 | isa = PBXSourcesBuildPhase;
259 | buildActionMask = 2147483647;
260 | files = (
261 | 50FA9A421B63AFA5009BF2A0 /* KeyboardMan.swift in Sources */,
262 | );
263 | runOnlyForDeploymentPostprocessing = 0;
264 | };
265 | /* End PBXSourcesBuildPhase section */
266 |
267 | /* Begin PBXTargetDependency section */
268 | 50FA9A371B63AF69009BF2A0 /* PBXTargetDependency */ = {
269 | isa = PBXTargetDependency;
270 | target = 50FA9A201B63AF69009BF2A0 /* KeyboardMan */;
271 | targetProxy = 50FA9A361B63AF69009BF2A0 /* PBXContainerItemProxy */;
272 | };
273 | /* End PBXTargetDependency section */
274 |
275 | /* Begin PBXVariantGroup section */
276 | 50FA9A001B63AEF0009BF2A0 /* Main.storyboard */ = {
277 | isa = PBXVariantGroup;
278 | children = (
279 | 50FA9A011B63AEF0009BF2A0 /* Base */,
280 | );
281 | name = Main.storyboard;
282 | sourceTree = "";
283 | };
284 | 50FA9A051B63AEF0009BF2A0 /* LaunchScreen.xib */ = {
285 | isa = PBXVariantGroup;
286 | children = (
287 | 50FA9A061B63AEF0009BF2A0 /* Base */,
288 | );
289 | name = LaunchScreen.xib;
290 | sourceTree = "";
291 | };
292 | /* End PBXVariantGroup section */
293 |
294 | /* Begin XCBuildConfiguration section */
295 | 50FA9A141B63AEF0009BF2A0 /* Debug */ = {
296 | isa = XCBuildConfiguration;
297 | buildSettings = {
298 | ALWAYS_SEARCH_USER_PATHS = NO;
299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
300 | CLANG_CXX_LIBRARY = "libc++";
301 | CLANG_ENABLE_MODULES = YES;
302 | CLANG_ENABLE_OBJC_ARC = YES;
303 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
304 | CLANG_WARN_BOOL_CONVERSION = YES;
305 | CLANG_WARN_COMMA = YES;
306 | CLANG_WARN_CONSTANT_CONVERSION = YES;
307 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
309 | CLANG_WARN_EMPTY_BODY = YES;
310 | CLANG_WARN_ENUM_CONVERSION = YES;
311 | CLANG_WARN_INFINITE_RECURSION = YES;
312 | CLANG_WARN_INT_CONVERSION = YES;
313 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
314 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
315 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
316 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
317 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
318 | CLANG_WARN_STRICT_PROTOTYPES = YES;
319 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
320 | CLANG_WARN_UNREACHABLE_CODE = YES;
321 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
322 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
323 | COPY_PHASE_STRIP = NO;
324 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
325 | ENABLE_STRICT_OBJC_MSGSEND = YES;
326 | ENABLE_TESTABILITY = YES;
327 | GCC_C_LANGUAGE_STANDARD = gnu99;
328 | GCC_DYNAMIC_NO_PIC = NO;
329 | GCC_NO_COMMON_BLOCKS = YES;
330 | GCC_OPTIMIZATION_LEVEL = 0;
331 | GCC_PREPROCESSOR_DEFINITIONS = (
332 | "DEBUG=1",
333 | "$(inherited)",
334 | );
335 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
336 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
337 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
338 | GCC_WARN_UNDECLARED_SELECTOR = YES;
339 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
340 | GCC_WARN_UNUSED_FUNCTION = YES;
341 | GCC_WARN_UNUSED_VARIABLE = YES;
342 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
343 | MTL_ENABLE_DEBUG_INFO = YES;
344 | ONLY_ACTIVE_ARCH = YES;
345 | SDKROOT = iphoneos;
346 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
347 | SWIFT_VERSION = 4.0;
348 | TARGETED_DEVICE_FAMILY = "1,2";
349 | };
350 | name = Debug;
351 | };
352 | 50FA9A151B63AEF0009BF2A0 /* Release */ = {
353 | isa = XCBuildConfiguration;
354 | buildSettings = {
355 | ALWAYS_SEARCH_USER_PATHS = NO;
356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
357 | CLANG_CXX_LIBRARY = "libc++";
358 | CLANG_ENABLE_MODULES = YES;
359 | CLANG_ENABLE_OBJC_ARC = YES;
360 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
361 | CLANG_WARN_BOOL_CONVERSION = YES;
362 | CLANG_WARN_COMMA = YES;
363 | CLANG_WARN_CONSTANT_CONVERSION = YES;
364 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
365 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
366 | CLANG_WARN_EMPTY_BODY = YES;
367 | CLANG_WARN_ENUM_CONVERSION = YES;
368 | CLANG_WARN_INFINITE_RECURSION = YES;
369 | CLANG_WARN_INT_CONVERSION = YES;
370 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
371 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
372 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
374 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
375 | CLANG_WARN_STRICT_PROTOTYPES = YES;
376 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
377 | CLANG_WARN_UNREACHABLE_CODE = YES;
378 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
379 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
380 | COPY_PHASE_STRIP = NO;
381 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
382 | ENABLE_NS_ASSERTIONS = NO;
383 | ENABLE_STRICT_OBJC_MSGSEND = YES;
384 | GCC_C_LANGUAGE_STANDARD = gnu99;
385 | GCC_NO_COMMON_BLOCKS = YES;
386 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
387 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
388 | GCC_WARN_UNDECLARED_SELECTOR = YES;
389 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
390 | GCC_WARN_UNUSED_FUNCTION = YES;
391 | GCC_WARN_UNUSED_VARIABLE = YES;
392 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
393 | MTL_ENABLE_DEBUG_INFO = NO;
394 | SDKROOT = iphoneos;
395 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
396 | SWIFT_VERSION = 4.0;
397 | TARGETED_DEVICE_FAMILY = "1,2";
398 | VALIDATE_PRODUCT = YES;
399 | };
400 | name = Release;
401 | };
402 | 50FA9A171B63AEF0009BF2A0 /* Debug */ = {
403 | isa = XCBuildConfiguration;
404 | buildSettings = {
405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
406 | DEVELOPMENT_TEAM = 8D957V42M6;
407 | INFOPLIST_FILE = Messages/Info.plist;
408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
409 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)";
410 | PRODUCT_NAME = "$(TARGET_NAME)";
411 | SWIFT_VERSION = 4.2;
412 | };
413 | name = Debug;
414 | };
415 | 50FA9A181B63AEF0009BF2A0 /* Release */ = {
416 | isa = XCBuildConfiguration;
417 | buildSettings = {
418 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
419 | DEVELOPMENT_TEAM = 8D957V42M6;
420 | INFOPLIST_FILE = Messages/Info.plist;
421 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
422 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)";
423 | PRODUCT_NAME = "$(TARGET_NAME)";
424 | SWIFT_VERSION = 4.2;
425 | };
426 | name = Release;
427 | };
428 | 50FA9A3A1B63AF69009BF2A0 /* Debug */ = {
429 | isa = XCBuildConfiguration;
430 | buildSettings = {
431 | APPLICATION_EXTENSION_API_ONLY = YES;
432 | CLANG_ENABLE_MODULES = YES;
433 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
434 | CURRENT_PROJECT_VERSION = 1;
435 | DEFINES_MODULE = YES;
436 | DYLIB_COMPATIBILITY_VERSION = 1;
437 | DYLIB_CURRENT_VERSION = 1;
438 | DYLIB_INSTALL_NAME_BASE = "@rpath";
439 | GCC_PREPROCESSOR_DEFINITIONS = (
440 | "DEBUG=1",
441 | "$(inherited)",
442 | );
443 | INFOPLIST_FILE = KeyboardMan/Info.plist;
444 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
445 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
447 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)";
448 | PRODUCT_NAME = "$(TARGET_NAME)";
449 | SKIP_INSTALL = YES;
450 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
451 | SWIFT_VERSION = 4.2;
452 | VERSIONING_SYSTEM = "apple-generic";
453 | VERSION_INFO_PREFIX = "";
454 | };
455 | name = Debug;
456 | };
457 | 50FA9A3B1B63AF69009BF2A0 /* Release */ = {
458 | isa = XCBuildConfiguration;
459 | buildSettings = {
460 | APPLICATION_EXTENSION_API_ONLY = YES;
461 | CLANG_ENABLE_MODULES = YES;
462 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
463 | CURRENT_PROJECT_VERSION = 1;
464 | DEFINES_MODULE = YES;
465 | DYLIB_COMPATIBILITY_VERSION = 1;
466 | DYLIB_CURRENT_VERSION = 1;
467 | DYLIB_INSTALL_NAME_BASE = "@rpath";
468 | INFOPLIST_FILE = KeyboardMan/Info.plist;
469 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
470 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
471 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
472 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)";
473 | PRODUCT_NAME = "$(TARGET_NAME)";
474 | SKIP_INSTALL = YES;
475 | SWIFT_VERSION = 4.2;
476 | VERSIONING_SYSTEM = "apple-generic";
477 | VERSION_INFO_PREFIX = "";
478 | };
479 | name = Release;
480 | };
481 | /* End XCBuildConfiguration section */
482 |
483 | /* Begin XCConfigurationList section */
484 | 50FA99F21B63AEF0009BF2A0 /* Build configuration list for PBXProject "Messages" */ = {
485 | isa = XCConfigurationList;
486 | buildConfigurations = (
487 | 50FA9A141B63AEF0009BF2A0 /* Debug */,
488 | 50FA9A151B63AEF0009BF2A0 /* Release */,
489 | );
490 | defaultConfigurationIsVisible = 0;
491 | defaultConfigurationName = Release;
492 | };
493 | 50FA9A161B63AEF0009BF2A0 /* Build configuration list for PBXNativeTarget "Messages" */ = {
494 | isa = XCConfigurationList;
495 | buildConfigurations = (
496 | 50FA9A171B63AEF0009BF2A0 /* Debug */,
497 | 50FA9A181B63AEF0009BF2A0 /* Release */,
498 | );
499 | defaultConfigurationIsVisible = 0;
500 | defaultConfigurationName = Release;
501 | };
502 | 50FA9A3E1B63AF69009BF2A0 /* Build configuration list for PBXNativeTarget "KeyboardMan" */ = {
503 | isa = XCConfigurationList;
504 | buildConfigurations = (
505 | 50FA9A3A1B63AF69009BF2A0 /* Debug */,
506 | 50FA9A3B1B63AF69009BF2A0 /* Release */,
507 | );
508 | defaultConfigurationIsVisible = 0;
509 | defaultConfigurationName = Release;
510 | };
511 | /* End XCConfigurationList section */
512 | };
513 | rootObject = 50FA99EF1B63AEF0009BF2A0 /* Project object */;
514 | }
515 |
--------------------------------------------------------------------------------
/Messages.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Messages.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Messages.xcodeproj/xcshareddata/xcschemes/KeyboardMan.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Messages/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Messages
4 | //
5 | // Created by NIX on 15/7/25.
6 | // Copyright (c) 2015年 nixWork. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18 |
19 | print("application didFinishLaunchingWithOptions")
20 |
21 | return true
22 | }
23 |
24 | func applicationWillResignActive(_ application: UIApplication) {
25 |
26 | print("application applicationWillResignActive")
27 | }
28 |
29 | func applicationDidEnterBackground(_ application: UIApplication) {
30 |
31 | print("application applicationDidEnterBackground")
32 | }
33 |
34 | func applicationWillEnterForeground(_ application: UIApplication) {
35 |
36 | print("application applicationWillEnterForeground")
37 | }
38 |
39 | func applicationDidBecomeActive(_ application: UIApplication) {
40 |
41 | print("application applicationDidBecomeActive")
42 | }
43 |
44 | func applicationWillTerminate(_ application: UIApplication) {
45 |
46 | print("application applicationWillTerminate")
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/Messages/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Messages/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 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/Messages/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/Messages/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 | APPL
17 | CFBundleShortVersionString
18 | 1.2.3
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 15
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Messages/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Messages
4 | //
5 | // Created by NIX on 15/7/25.
6 | // Copyright (c) 2015年 nixWork. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import KeyboardMan
11 |
12 | class ViewController: UIViewController {
13 |
14 | @IBOutlet weak var tableView: UITableView!
15 |
16 | @IBOutlet weak var toolBar: UIView!
17 | @IBOutlet weak var toolBarBottomConstraint: NSLayoutConstraint!
18 |
19 | @IBOutlet weak var textField: UITextField!
20 |
21 | var messages: [String] = [
22 | "How do you do?",
23 | ]
24 |
25 | let cellID = "cell"
26 |
27 | let keyboardMan = KeyboardMan()
28 |
29 | override func viewDidLoad() {
30 | super.viewDidLoad()
31 |
32 | tableView.rowHeight = 60
33 | tableView.contentInset.bottom = toolBar.frame.height
34 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
35 | tableView.tableFooterView = UIView()
36 |
37 | keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in
38 |
39 | print("appear \(appearPostIndex), \(keyboardHeight), \(keyboardHeightIncrement)\n")
40 |
41 | if let self = self {
42 |
43 | self.tableView.contentOffset.y += keyboardHeightIncrement
44 | self.tableView.contentInset.bottom = keyboardHeight + self.toolBar.frame.height
45 |
46 | self.toolBarBottomConstraint.constant = keyboardHeight
47 | self.view.layoutIfNeeded()
48 | }
49 | }
50 |
51 | keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in
52 |
53 | print("disappear \(keyboardHeight)\n")
54 |
55 | if let self = self {
56 |
57 | self.tableView.contentOffset.y -= keyboardHeight
58 | self.tableView.contentInset.bottom = self.toolBar.frame.height
59 |
60 | self.toolBarBottomConstraint.constant = 0
61 | self.view.layoutIfNeeded()
62 | }
63 | }
64 |
65 | keyboardMan.postKeyboardInfo = { keyboardMan, keyboardInfo in
66 |
67 | switch keyboardInfo.action {
68 | case .show:
69 | print("show \(keyboardMan.appearPostIndex), \(keyboardInfo.height), \(keyboardInfo.heightIncrement)\n")
70 | case .hide:
71 | print("hide \(keyboardInfo.height)\n")
72 | }
73 |
74 | /*
75 | if let self = self {
76 |
77 | let duration = keyboardInfo.animationDuration
78 | let curve = keyboardInfo.animationCurve
79 | let options = UIViewAnimationOptions(rawValue: curve << 16 | UIViewAnimationOptions.beginFromCurrentState.rawValue)
80 |
81 | switch keyboardInfo.action {
82 |
83 | case .show:
84 |
85 | print("show \(keyboardMan.appearPostIndex), \(keyboardInfo.height), \(keyboardInfo.heightIncrement)\n")
86 |
87 | UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
88 |
89 | self.tableView.contentOffset.y += keyboardInfo.heightIncrement
90 | self.tableView.contentInset.bottom = keyboardInfo.height + self.toolBar.frame.height
91 |
92 | self.toolBarBottomConstraint.constant = keyboardInfo.height
93 | self.view.layoutIfNeeded()
94 |
95 | }, completion: nil)
96 |
97 | case .hide:
98 |
99 | print("hide \(keyboardInfo.height)\n")
100 |
101 | UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
102 |
103 | self.tableView.contentOffset.y -= keyboardInfo.height
104 | self.tableView.contentInset.bottom = self.toolBar.frame.height
105 |
106 | self.toolBarBottomConstraint.constant = 0
107 | self.view.layoutIfNeeded()
108 |
109 | }, completion: nil)
110 | }
111 | }
112 | */
113 | }
114 | }
115 |
116 | // MARK: - Actions
117 |
118 | func sendMessage(textField: UITextField) {
119 |
120 | guard let message = textField.text else {
121 | return
122 | }
123 |
124 | if message.isEmpty {
125 | return
126 | }
127 |
128 | // update data source
129 |
130 | messages.append(message)
131 |
132 | // insert new row
133 |
134 | let indexPath = IndexPath(row: messages.count - 1, section: 0)
135 | tableView.insertRows(at: [indexPath], with: .fade)
136 |
137 | // scroll up a little bit if need
138 |
139 | let newMessageHeight: CGFloat = tableView.rowHeight
140 |
141 | let blockedHeight = statusBarHeight + navigationBarHeight + toolBar.frame.height + toolBarBottomConstraint.constant
142 | let visibleHeight = tableView.frame.height - blockedHeight
143 | let hiddenHeight = tableView.contentSize.height - visibleHeight
144 |
145 | if hiddenHeight + newMessageHeight > 0 {
146 |
147 | let contentOffsetYIncrement = hiddenHeight > 0 ? newMessageHeight : hiddenHeight + newMessageHeight
148 | print("contentOffsetYIncrement: \(contentOffsetYIncrement)\n")
149 |
150 | UIView.animate(withDuration: 0.2) {
151 | self.tableView.contentOffset.y += contentOffsetYIncrement
152 | }
153 | }
154 |
155 | // clear text
156 |
157 | textField.text = ""
158 | }
159 | }
160 |
161 | // MARK: - Bar heights
162 |
163 | extension UIViewController {
164 |
165 | var statusBarHeight: CGFloat {
166 |
167 | if let window = view.window {
168 | let statusBarFrame = window.convert(UIApplication.shared.statusBarFrame, to: view)
169 | return statusBarFrame.height
170 |
171 | } else {
172 | return 0
173 | }
174 | }
175 |
176 | var navigationBarHeight: CGFloat {
177 |
178 | if let navigationController = navigationController {
179 | return navigationController.navigationBar.frame.height
180 |
181 | } else {
182 | return 0
183 | }
184 | }
185 | }
186 |
187 | // MARK: - UITextFieldDelegate
188 |
189 | extension ViewController: UITextFieldDelegate {
190 |
191 | func textFieldShouldReturn(_ textField: UITextField) -> Bool {
192 |
193 | sendMessage(textField: textField)
194 |
195 | return true
196 | }
197 | }
198 |
199 | // MARK: - UITableViewDataSource, UITableViewDelegate
200 |
201 | extension ViewController: UITableViewDataSource, UITableViewDelegate {
202 |
203 | private func numberOfSectionsInTableView(tableView: UITableView) -> Int {
204 |
205 | return 1
206 | }
207 |
208 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
209 |
210 | return messages.count
211 | }
212 |
213 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
214 |
215 | let cell = tableView.dequeueReusableCell(withIdentifier: cellID)!
216 |
217 | let message = messages[indexPath.row]
218 | cell.textLabel?.text = "\(indexPath.row + 1): " + message
219 |
220 | return cell
221 | }
222 |
223 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
224 |
225 | tableView.deselectRow(at: indexPath, animated: true)
226 |
227 | textField.resignFirstResponder()
228 | }
229 | }
230 |
231 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | # KeyboardMan
7 |
8 | We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistakes. Even more, we need to handle the bug of system fire keyboard notifications.
9 |
10 | But KeyboardMan will make it simple & easy.
11 |
12 | 另有[中文介绍](https://github.com/nixzhu/dev-blog/blob/master/2015-07-27-keyboard-man.md)。
13 |
14 | ## Requirements
15 |
16 | Swift 4.2, iOS 8.0
17 |
18 | (Swift 3, use version 1.1.0)
19 |
20 | ## Example
21 |
22 | ```swift
23 | import KeyboardMan
24 | ```
25 |
26 | Do animation with keyboard appear/disappear:
27 |
28 | ```swift
29 | let keyboardMan = KeyboardMan()
30 |
31 | keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in
32 |
33 | print("appear \(appearPostIndex), \(keyboardHeight), \(keyboardHeightIncrement)\n")
34 |
35 | if let self = self {
36 |
37 | self.tableView.contentOffset.y += keyboardHeightIncrement
38 | self.tableView.contentInset.bottom = keyboardHeight + self.toolBar.frame.height
39 |
40 | self.toolBarBottomConstraint.constant = keyboardHeight
41 | self.view.layoutIfNeeded()
42 | }
43 | }
44 |
45 | keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in
46 |
47 | print("disappear \(keyboardHeight)\n")
48 |
49 | if let self = self {
50 |
51 | self.tableView.contentOffset.y -= keyboardHeight
52 | self.tableView.contentInset.bottom = self.toolBar.frame.height
53 |
54 | self.toolBarBottomConstraint.constant = 0
55 | self.view.layoutIfNeeded()
56 | }
57 | }
58 | ```
59 |
60 | For more specific information, you can use keyboardInfo that KeyboardMan post:
61 |
62 | ```swift
63 | keyboardMan.postKeyboardInfo = { [weak self] keyboardMan, keyboardInfo in
64 | // TODO
65 | }
66 | ```
67 |
68 | Check the demo for more information.
69 |
70 | ## Installation
71 |
72 | Feel free to drag `KeyboardMan.swift` to your iOS Project. But it's recommended to use Carthage (or CocoaPods).
73 |
74 | ### Carthage
75 |
76 | ```ogdl
77 | github "nixzhu/KeyboardMan"
78 | ```
79 |
80 | ### CocoaPods
81 |
82 | ```ruby
83 | pod 'KeyboardMan'
84 | ```
85 |
86 | ## Contact
87 |
88 | NIX [@nixzhu](https://twitter.com/nixzhu)
89 |
90 | ## License
91 |
92 | KeyboardMan is available under the MIT license. See the LICENSE file for more info.
93 |
--------------------------------------------------------------------------------