I have long data modules title that overlap with the button on the right. This is a short data module title where the title does not overlap.
我有很长的数据模块标题,与右边的按钮重叠。这是一个短数据模块标题,标题不重叠。
For long data modules,I would wan to create a line break to go to the next line and display it there so it would not overlap
对于长数据模块,我想创建换行符以转到下一行并在那里显示它,以便它不会重叠
In my code I already set the MaskIntoConstrains to false, what else needs to be done for this functionality to work?
在我的代码中,我已经将MaskIntoConstrains设置为false,还需要做什么才能使此功能正常工作?
Code:
码:
func createDropDownMenu() {
// create the drop down menu
let title = prepareNavigationBarMenuTitleView()
prepareNavigationBarMenu(title)
updateMenuContentOffsets()
}
func prepareNavigationBarMenuTitleView() -> String {
// Both title label and image view are fixed horizontally inside title
// view, UIKit is responsible to center title view in the navigation bar.
// We want to ensure the space between title and image remains constant,
// even when title view is moved to remain centered (but never resized).
titleView = DropDownTitleView(frame: CGRect(x: 0, y: 0, width: 150, height: 40))
titleView.addTarget(self,
action: #selector(DocumentViewController.willToggleNavigationBarMenu(_:)),
for: .touchUpInside)
titleView.addTarget(self,
action: #selector(DocumentViewController.didToggleNavigationBarMenu(_:)),
for: .valueChanged)
titleView.titleLabel.textAlignment = .left
titleView.titleLabel.textColor = UIColor.black
titleView.titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleView.title = currentNode.title
navigationItem.titleView = titleView
return titleView.title!
}
1 个解决方案
#1
1
You are not setting the frame of Titlelabel
, set its frame along with set numberofLines = 0
will resolve your issue .
您没有设置Titlelabel的框架,设置其框架以及set numberofLines = 0将解决您的问题。
Here is the code :
这是代码:
titleView.titleLabel.frame = CGRect(x: 0, y: 0, width: 600, height: 80)
titleView.numberOfLines = 0
//Important one
titleView.titleLabel.text = currentNode.title
This will resolve your issue . Enjoy Coding .
这将解决您的问题。享受编码。
#1
1
You are not setting the frame of Titlelabel
, set its frame along with set numberofLines = 0
will resolve your issue .
您没有设置Titlelabel的框架,设置其框架以及set numberofLines = 0将解决您的问题。
Here is the code :
这是代码:
titleView.titleLabel.frame = CGRect(x: 0, y: 0, width: 600, height: 80)
titleView.numberOfLines = 0
//Important one
titleView.titleLabel.text = currentNode.title
This will resolve your issue . Enjoy Coding .
这将解决您的问题。享受编码。