我有带有 UIViewController 的 UINavigationBarDelegate 委托,我以编程的方式设置所有东西,我的应用程序是多语言的,所以我需要RTL (从右到左)在每个部分的支持,比如NavigationBar。我采用了这样的方法:
UIViewController
UINavigationBarDelegate
if MSGlobal.setting.language.direction == .L2R navigationItem.setRightBarButtonItems(rightItems, animated: true) navigationItem.setLeftBarButtonItems(rightItems, animated: true) let stackCount = navigationController!.viewControllers.count if stackCount == 1 let leftBtnItem:UIBarButtonItem = UIBarButtonItem(image: UIImage(named:"drawer"), landscapeImagePhone: UIImage(named:"drawer"), style: UIBarButtonItemStyle.Plain, target: self, action: "cb_drawerTapped:") if MSGlobal.setting.language.direction == .L2R navigationItem.setLeftBarButtonItem(leftBtnItem, animated: true) navigationItem.setRightBarButtonItem(leftBtnItem, animated: true)