Ios 将UIButton与UITextField文本垂直对齐

Ios 将UIButton与UITextField文本垂直对齐,ios,uibutton,autolayout,uitextview,nslayoutconstraint,Ios,Uibutton,Autolayout,Uitextview,Nslayoutconstraint,我想在文本视图文本的末尾添加一个“阅读更多”按钮。文本位于UITextView中,按钮为UIButton。首先,我想让按钮与textview最后一行垂直对齐 我正在获取layoutSubviews中文本视图文本容器的大小(这发生在UICollectionReusableView中): 我正在使用自动布局。我有一个约束(showAllButtonHeight)定义按钮的y值,定义如下: 如何使按钮与文本完全对齐?还是有更好的方法来制作这种“阅读更多”按钮 let containerSize =

我想在文本视图文本的末尾添加一个“阅读更多”按钮。文本位于
UITextView
中,按钮为
UIButton
。首先,我想让按钮与textview最后一行垂直对齐

我正在获取
layoutSubviews
中文本视图文本容器的大小(这发生在
UICollectionReusableView
中):

我正在使用自动布局。我有一个约束(
showAllButtonHeight
)定义按钮的y值,定义如下:

如何使按钮与文本完全对齐?还是有更好的方法来制作这种“阅读更多”按钮

let containerSize = descriptionTextView.layoutManager.usedRectForTextContainer(descriptionTextView.textContainer).size
showAllButtonHeight.constant = containerSize.height