在不断增长的文本视图中,UIBUTTON位置到UITEXTVIEW的右侧

发布于 2025-01-28 20:54:37 字数 765 浏览 4 评论 0原文

我在文本视图中有一个uibutton()。

let expanButtonHeight = bounds.size.height
     expanButton.frame = CGRect(x: textView.bounds.size.width - expanButtonHeight, y: 0, width: expanButtonHeight, height: expanButtonHeight)

     self.addSubview(expanButton)
     self.layoutIfNeeded()

但是,当我在文本视图中键入文本时,ExpanButton不会改变。即使文本视图的宽度增长,我如何将UIBUTTON位置固定在UITEXTVIEW的右侧?

这是我面临的问题:

我希望按钮在textView的末尾留下:

I have a UIButton() in a textView.

let expanButtonHeight = bounds.size.height
     expanButton.frame = CGRect(x: textView.bounds.size.width - expanButtonHeight, y: 0, width: expanButtonHeight, height: expanButtonHeight)

     self.addSubview(expanButton)
     self.layoutIfNeeded()

But when I type text in my textView the expanButton doesn't change. How do I keep the UIButton position fixed at right side of UITextView even when textView is growing in width?

This is the problem I'm facing:
This is the problem I'm facing

I want the button to stay at end of textView:
I want the button to stay at end of textView

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宣告ˉ结束 2025-02-04 20:54:37

有了您希望,我建议您将Uiview作为UitextView和Uibutton的父容器。您的按钮应添加到Uiview而不是添加到UitextView中。如果UITEXTVIEW增长,请使父容器Uiview也会增长,并且您可以根据Uiview的任何位置将Uibutton粘贴在您想要的任何地方。

With what you wish, I suggest you to have a UIView as a parent container of UITextView and UIButton. Your button should add to UIView instead of adding to UITextView. if the UITextView grow, make the parent container UIView grow as well and you can stick your UIButton at any place you want based on UIView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文