自定义栏按钮与图像和标题

时间:2017-05-23 12:02:43

标签: swift uinavigationbar uinavigationitem

当我使用带有图像和标题的自定义栏按钮时,我遇到了问题,我使用下面的代码

using (SpreadsheetDocument spreadsheetDocument = File.Exists(filePath) ?
SpreadsheetDocument.Open(filepath, true) : 
SpreadsheetDocument.Create(filepath, SpreadsheetDocumentType.Workbook))
   {

   }

这是问题片段。文字没有清楚显示

The text not shows clearly

1 个答案:

答案 0 :(得分:-1)

试试这个:

    let backButton = UIButton(type: .system)
    backButton.frame = CGRect(x: 0, y: 0, width: 500, height: 30)
    backButton.setImage(buttonImg, for: .normal)
    backButton.setTitle(title, for: .normal)
    backButton.addTarget(self, action: #selector(self.popVC(_:)), for: .touchUpInside)
    backButton.sizeToFit()
    let backBarButton = UIBarButtonItem(customView: backButton)
    self.navigationItem.leftBarButtonItem = backBarButton