@@ -119,6 +119,15 @@ public final class MessageView: UIView, MessageTextViewListener {
119119 get { return textView. textContainerInset }
120120 }
121121
122+ public var contentInset : UIEdgeInsets {
123+ set {
124+ textView. contentInset = newValue
125+ setNeedsLayout ( )
126+ delegate? . wantsLayout ( messageView: self )
127+ }
128+ get { return textView. contentInset }
129+ }
130+
122131 /// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
123132 /// If none is supplied, it will default to the icon's `accessibilityLabel`.
124133 public func setButton( icon: UIImage ? , for state: UIControlState , position: ButtonPosition , accessibilityLabel: String ? = nil ) {
@@ -273,13 +282,20 @@ public final class MessageView: UIView, MessageTextViewListener {
273282 let textViewMaxY = textViewY + textViewHeight
274283
275284 // adjust for font descender so button aligns with the text baseline
276- let descenderAdjustment = floor ( textView. font? . descender ?? 0 )
277- let buttonYStarter = textViewMaxY - textViewInset. bottom + descenderAdjustment
285+ let descender , pointSize : CGFloat
286+ if let font = textView. font {
287+ descender = floor ( font. descender)
288+ pointSize = ceil ( font. pointSize)
289+ } else {
290+ descender = 0
291+ pointSize = 0
292+ }
293+ let buttonYStarter = textViewMaxY - textViewInset. bottom - ( pointSize - descender) / 2
278294
279295 // adjust by bottom offset so content is flush w/ text view
280296 let leftButtonFrame = CGRect (
281297 x: safeBounds. minX + leftButtonInset,
282- y: buttonYStarter - leftButtonSize. height + leftButton. bottomHeightOffset,
298+ y: buttonYStarter - leftButtonSize. height/ 2 + leftButton. bottomHeightOffset,
283299 width: leftButtonSize. width,
284300 height: leftButtonSize. height
285301 )
@@ -297,7 +313,7 @@ public final class MessageView: UIView, MessageTextViewListener {
297313 // adjust by bottom offset so content is flush w/ text view
298314 let rightButtonFrame = CGRect (
299315 x: textViewFrame. maxX,
300- y: buttonYStarter - rightButtonSize. height + rightButton. bottomHeightOffset,
316+ y: buttonYStarter - rightButtonSize. height/ 2 + rightButton. bottomHeightOffset,
301317 width: rightButtonSize. width,
302318 height: rightButtonSize. height
303319 )
0 commit comments