         titleHeightConstraint = titleTextField.heightAnchor.constraint(equalToConstant: titleTextField.font!.lineHeight)
         titleTopConstraint = titleTextField.topAnchor.constraint(equalTo: view.topAnchor, constant: -richTextView.contentOffset.y)
         updateTitleHeight()
+        let layoutGuide = view.layoutMarginsGuide
+
         NSLayoutConstraint.activate([
-            titleTextField.leftAnchor.constraint(equalTo: view.leftAnchor, constant: Constants.margin),
-            titleTextField.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -Constants.margin),
+            titleTextField.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor, constant: 0),
+            titleTextField.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor, constant: 0),
             titleTopConstraint,
             titleHeightConstraint
             ])
 
         let insets = titleTextField.textContainerInset
         NSLayoutConstraint.activate([
-            titlePlaceholderLabel.leftAnchor.constraint(equalTo: titleTextField.leftAnchor, constant: insets.left + titleTextField.textContainer.lineFragmentPadding),
-            titlePlaceholderLabel.rightAnchor.constraint(equalTo: titleTextField.rightAnchor, constant: -insets.right),
+            titlePlaceholderLabel.leadingAnchor.constraint(equalTo: titleTextField.leadingAnchor, constant: insets.left + titleTextField.textContainer.lineFragmentPadding),
+            titlePlaceholderLabel.trailingAnchor.constraint(equalTo: titleTextField.trailingAnchor, constant: -insets.right),
             titlePlaceholderLabel.topAnchor.constraint(equalTo: titleTextField.topAnchor, constant: insets.top),
             titlePlaceholderLabel.heightAnchor.constraint(equalToConstant: titleTextField.font!.lineHeight)
             ])
-
         NSLayoutConstraint.activate([
-            separatorView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: Constants.margin),
-            separatorView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -Constants.margin),
+            separatorView.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor, constant: 0),
+            separatorView.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor, constant: 0),
             separatorView.topAnchor.constraint(equalTo: titleTextField.bottomAnchor, constant: 0),
             separatorView.heightAnchor.constraint(equalToConstant: separatorView.frame.height)
             ])
 
         NSLayoutConstraint.activate([
-            richTextView.leftAnchor.constraint(equalTo: view.leftAnchor),
-            richTextView.rightAnchor.constraint(equalTo: view.rightAnchor),
-            richTextView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
-            richTextView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -Constants.margin)
+            richTextView.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor),
+            richTextView.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor),
+            richTextView.topAnchor.constraint(equalTo: layoutGuide.topAnchor, constant: 0),
+            richTextView.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor, constant: 0)
             ])
 
         NSLayoutConstraint.activate([
-            htmlTextView.leftAnchor.constraint(equalTo: richTextView.leftAnchor),
-            htmlTextView.rightAnchor.constraint(equalTo: richTextView.rightAnchor),
+            htmlTextView.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor),
+            htmlTextView.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor),
             htmlTextView.topAnchor.constraint(equalTo: richTextView.topAnchor),
             htmlTextView.bottomAnchor.constraint(equalTo: richTextView.bottomAnchor),
             ])

        textView.keyboardDismissMode = .interactive
        textView.textColor = UIColor.darkText
        textView.translatesAutoresizingMaskIntoConstraints = false
        textView.textContainerInset.left = Constants.margin
        textView.textContainerInset.right = Constants.margin
    }

    private func registerAttachmentImageProviders() {

    func updateTitleHeight() {
        let referenceView: UIScrollView = editingMode == .richText ? richTextView : htmlTextView

        let sizeThatShouldFitTheContent = titleTextField.sizeThatFits(CGSize(width:view.frame.width, height: CGFloat.greatestFiniteMagnitude))
        let insets = titleTextField.textContainerInset
        titleHeightConstraint.constant = max(sizeThatShouldFitTheContent.height, titleTextField.font!.lineHeight + insets.top + insets.bottom)

