|
@@ -137,15 +137,23 @@ open class TSBaseVC: UIViewController {
|
|
|
|
|
|
// MARK: - 导航栏方法
|
|
|
|
|
|
- public func setTitleText(_ title: String) {
|
|
|
+ public func setTitleText(_ title: String,image:UIImage? = nil,spacing:CGFloat = 0,imageRight:Bool = false) -> UIButton {
|
|
|
addNormalNavBarView()
|
|
|
- _ = normalNavBarView.setTitleName(NSLocalizedString(title, comment: ""))
|
|
|
+ let titleNavBtn = normalNavBarView.setTitleName(NSLocalizedString(title, comment: ""))
|
|
|
+ UIButton.createButton()
|
|
|
+ if let image = image {
|
|
|
+ titleNavBtn.setImage(image, for: .normal)
|
|
|
+ }
|
|
|
+ titleNavBtn.semanticContentAttribute = imageRight ? .forceRightToLeft : .forceLeftToRight // 确保布局方向
|
|
|
+ titleNavBtn.contentEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: spacing) // 只调整 title 的 left
|
|
|
+ titleNavBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -spacing) // 只调整 image 的 right
|
|
|
+ return titleNavBtn
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public func setPageTitle(_ title: String) {
|
|
|
let pageTitle = title
|
|
|
let backTitle = " "
|
|
|
- setTitleText(pageTitle)
|
|
|
+ _ = setTitleText(pageTitle)
|
|
|
_ = setNavigationItem(backTitle, imageName: "navi_back_white", direction: .left, action: #selector(navBarClickLeftAction))
|
|
|
}
|
|
|
|