UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default)
我在上面使用它来移除iOS 11之前的backButtonTitle
但是在iOS 11上没有正常工作。
箭头向下移动。
如何解决这个问题?
编辑:通过删除标题的其他方式可以解决我的问题,但我担心的是为什么旧方法不再起作用。
答案 0 :(得分:3)
另一种方法是为navigationController设置<<<<<<< HEAD
...
=======
...
>>>>>>> master
并删除其功能中的标题。
UINavigationControllerDelegate
答案 1 :(得分:0)
使用此代码,
drop table if exists enrolledtable;
drop table if exists coursetable;
drop table if exists studenttable;
CREATE TABLE studenttable(
nickname VARCHAR(45),
pass VARCHAR(45),
PRIMARY KEY (nickname)
);
CREATE TABLE coursetable(
subject VARCHAR(45),
course VARCHAR(45),
cname VARCHAR(45),
credit INT,
PRIMARY KEY (subject, course),
key k1 (course) #added
);
CREATE TABLE enrolledtable (
nickname VARCHAR(45),
subject VARCHAR(45),
course VARCHAR(45),
PRIMARY KEY (nickname, subject, course),
FOREIGN KEY (nickname) REFERENCES studenttable (nickname),
FOREIGN KEY (subject) REFERENCES coursetable (subject),
FOREIGN KEY (course) REFERENCES coursetable (course)
);
答案 2 :(得分:0)
创建导航控制器类,如下所示。分配这个&#34; CustomNavViewController&#34;到你的StoryBoard中的UINavigationController
class CustomNavViewController: UINavigationController,UINavigationControllerDelegate
{
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func navigationController(
_ navigationController: UINavigationController,
willShow viewController: UIViewController,
animated: Bool
) {
viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
}
}
因此,无需在每个viewControllers中执行此操作。 最后从AppDelegate类中移除以下行,如果存在,
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), for:UIBarMetrics.default)
答案 3 :(得分:0)
不是垂直移动标题,而是可以水平移动。如果标题很长,你可以使它的颜色透明。工作得很好我:
let barButtonItemAppearance = UIBarButtonItem.appearance()
barButtonItemAppearance.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .normal)
barButtonItemAppearance.setBackButtonTitlePositionAdjustment(UIOffsetMake(-200, 0), for:UIBarMetrics.default)