uibutton位置位于swift的textview的右下角
我有一个自定义类uiview,其中我有一个文本视图。而且我正在尝试使用AutororesizingMask编程地将Uibutton添加到textView的右下角。这是我的代码:
public init() {
textViewButton = UIButton(type: .custom)
textViewButton.addTarget(self, action: #selector(didPressButton), for: .touchUpInside)
textViewButton.autoresizingMask = [.flexibleTopMargin, .flexibleRightMargin, .flexibleLeftMargin]
self.addSubview(textViewButton)
textViewButton.isHidden = true
}
我在LayoutsUbViews中设置帧:
override public func layoutSubviews() {
super.layoutSubviews()
textViewButton.frame = CGRect(x: bounds.maxX - 50, y: 0, width: 50, height: 50)
}
这是使用我的代码的按钮的当前位置: 这是带有空文本的当前位置 这是我代码的当前位置
我如何将按钮固定到textView的右下角?
I have a custom class UIView in which i have a textView. And I'm trying to add UIButton to bottom right corner of textView programmatically using autoresizingMask.This is my code:
public init() {
textViewButton = UIButton(type: .custom)
textViewButton.addTarget(self, action: #selector(didPressButton), for: .touchUpInside)
textViewButton.autoresizingMask = [.flexibleTopMargin, .flexibleRightMargin, .flexibleLeftMargin]
self.addSubview(textViewButton)
textViewButton.isHidden = true
}
And I'm setting frame in layoutSubviews:
override public func layoutSubviews() {
super.layoutSubviews()
textViewButton.frame = CGRect(x: bounds.maxX - 50, y: 0, width: 50, height: 50)
}
This is the current position of the button with my code:
This is the current position with empty text
This is the current position with my code
How do I fix the button to bottom right corner of textView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论