在不断增长的文本视图中,UIBUTTON位置到UITEXTVIEW的右侧
我在文本视图中有一个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的右侧?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有了您希望,我建议您将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.