Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

ios - swift: Removing an UI element from Others in a tab bar controller

I'm creating an app that utilize a floating button. I added the floating button programmatically in a UITabBarController class, everything works fine.

I want to remove this Floating button in the more tab only and if theres any way to rename the more button

image

Heres the UITabBarController Code:

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //LanguageModel.CurrentLanguage = currentlanguage
        FloatingBtnSetUpLanguage()
    }

    private func FloatingBtnSetUpLanguage() {
        let actionButton = JJFloatingActionButton()
        actionButton.buttonImage = UIImage(named: "lggsmenu")
        actionButton.buttonColor = .white
        actionButton.addItem(title: "???????", image: UIImage(named: "ar")) { item in
            self.changeView(lang: "ar")
        }
        actionButton.addItem(title: "French", image: UIImage(named: "fr")) { item in
            self.changeView(lang: "fr")
        }
        actionButton.addItem(title: "English", image: UIImage(named: "en")) { item in
            self.changeView(lang: "en")
        }

        view.addSubview(actionButton)
        actionButton.translatesAutoresizingMaskIntoConstraints = false
        actionButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16).isActive = true
        actionButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10).isActive = true
        actionButton.itemAnimationConfiguration = .slideIn(withInterItemSpacing: -100, firstItemSpacing: -75)
    }
    
    func changeView(lang: String) {
        if ModelManager.getInstance().UpdateDefaultLanguage(language: lang) {
            print("language changed to: (lang)")
            LanguageModel.CurrentLanguage = lang
            MOLH.setLanguageTo(lang)
            if #available(iOS 13.0, *) {
                let delegate = UIApplication.shared.delegate as? AppDelegate
                delegate!.swichRoot()
            } else {
                MOLH.reset()
            }
        }
    }
question from:https://stackoverflow.com/questions/65855515/swift-removing-an-ui-element-from-others-in-a-tab-bar-controller

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...