lays out in iOS11, but doesn't resize

pull/1/head
Michael Kirk 7 years ago committed by sdkjfhsdkjhfsdlkjhfsdf
parent 03e786a145
commit 3a078c831d

@ -221,7 +221,11 @@ public class AttachmentApprovalViewController: OWSViewController, MessagingToolb
} }
override public var inputAccessoryView: UIView? { override public var inputAccessoryView: UIView? {
return self.bottomToolbar self.bottomToolbar.layoutIfNeeded()
return self.bottomToolbarO
// let toolbar = UIView(frame: CGRect(origin: CGPoint.zero, size: CGSize(width: 50, height: 100)))
// toolbar.backgroundColor = UIColor.purple
// return toolbar
} }
override public var canBecomeFirstResponder: Bool { override public var canBecomeFirstResponder: Bool {
@ -391,7 +395,7 @@ protocol MessagingToolbarDelegate: class {
func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar) func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar)
} }
class MessagingToolbar: UIToolbar, UITextViewDelegate { class MessagingToolbar: UIView, UITextViewDelegate {
// let toolbar: UIToolbar // let toolbar: UIToolbar
// var sendButton: UIBarButtonItem! // var sendButton: UIBarButtonItem!
private var sendButton: UIButton! private var sendButton: UIButton!
@ -459,36 +463,40 @@ class MessagingToolbar: UIToolbar, UITextViewDelegate {
sendButton.titleLabel?.font = UIFont.ows_mediumFont(withSize: 16) sendButton.titleLabel?.font = UIFont.ows_mediumFont(withSize: 16)
sendButton.titleLabel?.textAlignment = .center sendButton.titleLabel?.textAlignment = .center
sendButton.tintColor = UIColor.ows_materialBlue() sendButton.tintColor = UIColor.ows_materialBlue()
// Increase hit area of send button
let sendButtonItem = UIBarButtonItem(customView: sendButton) sendButton.contentEdgeInsets = UIEdgeInsets(top: 20, left: 8, bottom: 4, right: 8)
// self.items = [textViewItem, sendButton] addSubview(sendButton)
self.items = [textViewItem, sendButtonItem] addSubview(textView)
// toolbar doesn't render without some minimum height set. //
// self.heightConstraint = self.autoSetDimension(.height, // let sendButtonItem = UIBarButtonItem(customView: sendButton)
//
// // self.items = [textViewItem, sendButton]
// self.items = [textViewItem, sendButtonItem]
//
// // toolbar doesn't render without some minimum height set.
// // self.heightConstraint = self.autoSetDimension(.height,
self.autoSetDimension(.height, self.autoSetDimension(.height,
toSize: kMinTextViewHeight + kToolbarMargin * 2, toSize: kMinTextViewHeight + kToolbarMargin * 2,
relation: .greaterThanOrEqual) relation: .greaterThanOrEqual)
//
// Adding textView to a toolbar item inserts it into a "hostView" // Adding textView to a toolbar item inserts it into a "hostView"
// This isn't really documentd, but I've verified it works on iOS10 // This isn't really documentd, but I've verified it works on iOS9 and iOS10
self.textViewHeightConstraint = textView.autoSetDimension(.height, toSize: kMinTextViewHeight) self.textViewHeightConstraint = textView.autoSetDimension(.height, toSize: kMinTextViewHeight)
textView.autoPinEdge(toSuperviewEdge: .leading, withInset: kToolbarMargin) textView.autoPinEdge(toSuperviewEdge: .leading, withInset: kToolbarMargin)
textView.autoPinEdge(toSuperviewEdge: .top, withInset: kToolbarMargin) textView.autoPinEdge(toSuperviewEdge: .top, withInset: kToolbarMargin)
textView.autoPinEdge(toSuperviewEdge: .bottom, withInset: kToolbarMargin) textView.autoPinEdge(toSuperviewEdge: .bottom, withInset: kToolbarMargin)
//
// let kTrailingOffset: CGFloat = kSendButtonWidth // // let kTrailingOffset: CGFloat = kSendButtonWidth
// textView.autoPinEdge(toSuperviewEdge: .trailing, withInset: kTrailingOffset) // // textView.autoPinEdge(toSuperviewEdge: .trailing, withInset: kTrailingOffset)
//
textView.autoPinEdge(.trailing, to: .leading, of: sendButton, withOffset: -8) textView.autoPinEdge(.trailing, to: .leading, of: sendButton, withOffset: -8)
sendButton.sizeToFit() sendButton.sizeToFit()
sendButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: kToolbarMargin) sendButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: kToolbarMargin)
sendButton.autoPinEdge(toSuperviewEdge: .bottom, withInset: kToolbarMargin) sendButton.autoPinEdge(toSuperviewEdge: .bottom, withInset: kToolbarMargin)
// Increase hit area of send button
sendButton.contentEdgeInsets = UIEdgeInsets(top: 20, left: 8, bottom: 4, right: 8)
textView.delegate = self textView.delegate = self
} }

Loading…
Cancel
Save