0
我有long data modules title重叠与右边的按钮。这是标题不重叠的short data module title。下拉菜单标题重叠与酒吧按钮 - 斯威夫特
对于长期数据模块,我会想新建一个换行符去到下一行并显示它有那么它不会重叠
在我的代码我已经设置MaskIntoConstrains为false,还有什么需要完成此功能的工作?
代码:
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!
}
尝试此代码titleView.titleLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping label.numberOfLines = 0 –