Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix consider safeAreaLayoutGuide in iOS11 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions KeyboardAdjuster.podspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# vim: ft=ruby

Pod::Spec.new do |s|

s.name = "KeyboardAdjuster"
s.version = "3.0.3"
s.version = "3.1.1"
s.summary = "Automatically resizes and adjust views to scroll when a keyboard appears."
s.homepage = "https://github.com/lionheart/KeyboardAdjuster"
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
Expand All @@ -11,12 +12,8 @@ Pod::Spec.new do |s|
s.social_media_url = 'https://twitter.com/dwlz'
s.documentation_url = 'https://code.lionheart.software/KeyboardAdjuster/'

s.platform = :ios, '9.3'
s.requires_arc = true

s.pod_target_xcconfig = {
'SWIFT_VERSION' => '4.0'
}

s.source_files = 'Pod/Classes/**/*'
s.platform = :ios, '9.3'
s.requires_arc = true
s.swift_version = '4.0'
s.source_files = 'Pod/Classes/**/*'
end
2 changes: 1 addition & 1 deletion KeyboardAdjuster.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Lionheart Software LLC";
TargetAttributes = {
3736F8FE1C763B9100666FB1 = {
Expand Down
15 changes: 11 additions & 4 deletions Pod/Classes/KeyboardAdjuster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ public class KeyboardLayoutGuide: UILayoutGuide {

view.addLayoutGuide(self)

leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
constraint = topAnchor.constraint(equalTo: view.bottomAnchor)
if #available(iOS 11.0, *) {
leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
constraint = topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
} else {
leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
constraint = topAnchor.constraint(equalTo: view.bottomAnchor)
}
constraint.isActive = true
}

Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ pod "KeyboardAdjuster", "~> 3"
}
```

<details>
<summary><strong>NOTE:</strong> If you're using iOS 11 and your view is using the <code>safeAreaLayoutGuide</code> to set constraints, click here to view an alternate approach.</summary>

```swift
func viewDidLoad() {
super.viewDidLoad()

tableView.bottomAnchor.constraint(lessThanOrEqualTo: keyboardLayoutGuide.topAnchor).isActive = true
}
```
</details>

3. And you're done! Whenever a keyboard appears, your view will be automatically resized.

## Optional Features
Expand Down