@@ -119,6 +119,15 @@ public final class MessageView: UIView, MessageTextViewListener {
119
119
get { return textView. textContainerInset }
120
120
}
121
121
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
+
122
131
/// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
123
132
/// If none is supplied, it will default to the icon's `accessibilityLabel`.
124
133
public func setButton( icon: UIImage ? , for state: UIControlState , position: ButtonPosition , accessibilityLabel: String ? = nil ) {
@@ -273,13 +282,20 @@ public final class MessageView: UIView, MessageTextViewListener {
273
282
let textViewMaxY = textViewY + textViewHeight
274
283
275
284
// 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
278
294
279
295
// adjust by bottom offset so content is flush w/ text view
280
296
let leftButtonFrame = CGRect (
281
297
x: safeBounds. minX + leftButtonInset,
282
- y: buttonYStarter - leftButtonSize. height + leftButton. bottomHeightOffset,
298
+ y: buttonYStarter - leftButtonSize. height/ 2 + leftButton. bottomHeightOffset,
283
299
width: leftButtonSize. width,
284
300
height: leftButtonSize. height
285
301
)
@@ -297,7 +313,7 @@ public final class MessageView: UIView, MessageTextViewListener {
297
313
// adjust by bottom offset so content is flush w/ text view
298
314
let rightButtonFrame = CGRect (
299
315
x: textViewFrame. maxX,
300
- y: buttonYStarter - rightButtonSize. height + rightButton. bottomHeightOffset,
316
+ y: buttonYStarter - rightButtonSize. height/ 2 + rightButton. bottomHeightOffset,
301
317
width: rightButtonSize. width,
302
318
height: rightButtonSize. height
303
319
)
0 commit comments