【问题标题】:move the navigation item Title to the right side of your navigation bar in Swift在 Swift 中将导航项标题移动到导航栏的右侧
【发布时间】:2021-06-17 12:14:31
【问题描述】:

我想将导航项“Qaustion”移动到导航栏的右侧

在 UIKit 中的 Swift 中

import UIKit

class ViewController3: UIViewController {
override func viewDidLoad() {
    super.viewDidLoad()

    title = "Navigation"
}
}

【问题讨论】:

标签: swift


【解决方案1】:

这张照片在这个回复里 只有输入按钮时方向才会改变

【讨论】:

    【解决方案2】:

    更改内容和导航方向从右到左从左到右

    override func viewDidLoad() {
        super.viewDidLoad()
    
        self.refreshView()
    
        navigationController.view.semanticContentAttribute = .forceRightToLeft
        self.navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    
        self.view.semanticContentAttribute = .forceLeftToRight
        // or
        // UIView.appearance().semanticContentAttribute = .forceRightToLeft
    
        //self.refreshView()
    }
    
    func refreshView() {
        let window = self.view.superview
        self.view.removeFromSuperview()
        window?.addSubview(self.view)
    }
    

    参考 - https://developer.apple.com/documentation/uikit/uiview/1622461-semanticcontentattribute

    【讨论】:

    • 很好,他改变了方向,但只输入了按钮 ، 在第一个视图中,它仍然向左移动
    • 什么都没发生,结果一样
    • 没什么变化,我附上一张图片
    • 没错,一切都结束了
    • 所有视图都没有改变
    猜你喜欢
    • 2016-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 1970-01-01
    • 2023-02-14
    • 1970-01-01
    相关资源
    最近更新 更多