Skip to content

Commit

Permalink
4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nathantannar4 committed Sep 26, 2018
1 parent e154ff7 commit a0e381a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion InputBarAccessoryView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }

# 2 - Version
s.version = "4.0.0"
s.version = "4.0.1"

# 3 - License
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
6 changes: 3 additions & 3 deletions InputBarAccessoryView/InputBarAccessoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,20 @@ open class InputBarAccessoryView: UIView {
activateConstraints()
}

/// Respect iPhone X safeAreaInsets
/// Respect window safeAreaInsets
/// Adds a constraint to anchor the bottomAnchor of the contentView to the window's safeAreaLayoutGuide.bottomAnchor
///
/// - Parameter window: The window to anchor to
private func setupConstraints(to window: UIWindow?) {
if #available(iOS 11.0, *) {
guard UIScreen.main.nativeBounds.height == 2436 else { return }
if let window = window {
guard window.safeAreaInsets.bottom > 0 else { return }
windowAnchor?.isActive = false
windowAnchor = contentView.bottomAnchor.constraint(lessThanOrEqualToSystemSpacingBelow: window.safeAreaLayoutGuide.bottomAnchor, multiplier: 1)
windowAnchor?.constant = -padding.bottom
windowAnchor?.priority = UILayoutPriority(rawValue: 750)
windowAnchor?.isActive = true
backgroundViewBottomAnchor?.constant = 34
backgroundViewBottomAnchor?.constant = window.safeAreaInsets.bottom
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion InputBarAccessoryView/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.3.0</string>
<string>4.0.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
32 changes: 26 additions & 6 deletions InputBarAccessoryView/Views/InputTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ open class InputTextView: UITextView {
/// The UIEdgeInsets the placeholderLabel has within the InputTextView
open var placeholderLabelInsets: UIEdgeInsets = UIEdgeInsets(top: 8, left: 4, bottom: 8, right: 4) {
didSet {
layoutSubviews()
updateConstraintsForPlaceholderLabel()
}
}

Expand Down Expand Up @@ -167,14 +167,25 @@ open class InputTextView: UITextView {
left: .leastNonzeroMagnitude,
bottom: .leastNonzeroMagnitude,
right: .leastNonzeroMagnitude)
setupPlaceholderLabel()
setupObservers()
addSubview(placeholderLabel)
}

/// Layout subviews based on edge insets
open override func layoutSubviews() {
super.layoutSubviews()
placeholderLabel.frame = bounds.inset(by: placeholderLabelInsets)
/// Adds the placeholderLabel to the view and sets up its initial constraints
private func setupPlaceholderLabel() {

addSubview(placeholderLabel)
placeholderLabelConstraintSet = NSLayoutConstraintSet(
top: placeholderLabel.topAnchor.constraint(equalTo: topAnchor, constant: placeholderLabelInsets.top),
bottom: placeholderLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -placeholderLabelInsets.bottom),
left: placeholderLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: placeholderLabelInsets.left),
right: placeholderLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -placeholderLabelInsets.right),
centerX: placeholderLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
centerY: placeholderLabel.centerYAnchor.constraint(equalTo: centerYAnchor)
)
placeholderLabelConstraintSet?.centerX?.priority = .defaultLow
placeholderLabelConstraintSet?.centerY?.priority = .defaultLow
placeholderLabelConstraintSet?.activate()
}

/// Adds a notification for .UITextViewTextDidChange to detect when the placeholderLabel
Expand All @@ -188,6 +199,15 @@ open class InputTextView: UITextView {
selector: #selector(InputTextView.textViewTextDidChange),
name: UITextView.textDidChangeNotification, object: nil)
}

/// Updates the placeholderLabels constraint constants to match the placeholderLabelInsets
private func updateConstraintsForPlaceholderLabel() {

placeholderLabelConstraintSet?.top?.constant = placeholderLabelInsets.top
placeholderLabelConstraintSet?.bottom?.constant = -placeholderLabelInsets.bottom
placeholderLabelConstraintSet?.left?.constant = placeholderLabelInsets.left
placeholderLabelConstraintSet?.right?.constant = -placeholderLabelInsets.right
}

// MARK: - Notifications

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ private var onDisabledAction: InputBarButtonItemAction?
```

## Changelog
- 4.0.1
- Fix window constraint for iPhone Xs, Xs Max and XR
- 4.0.0
- Update to Swift 4.2
- 3.1.0
Expand Down

0 comments on commit a0e381a

Please sign in to comment.