gpt4 book ai didi

swift - 下拉菜单标题与条形按钮重叠 - Swift

转载 作者:行者123 更新时间:2023-11-28 15:37:22 24 4
gpt4 key购买 nike

我有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!
}

最佳答案

您没有设置 Titlelabel 的框架,设置它的框架以及设置 numberofLines = 0 将解决您的问题。

代码如下:

titleView.titleLabel.frame = CGRect(x: 0, y: 0, width: 600, height: 80)
titleView.numberOfLines = 0
//Important one
titleView.titleLabel.text = currentNode.title

这将解决您的问题。享受编码。

关于swift - 下拉菜单标题与条形按钮重叠 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44161595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com