Добавлена ​​кнопка в большой панели навигации заголовка - PullRequest
1 голос
/ 10 июня 2019

Я добавил кнопку в большую панель навигации заголовка. Я хочу сделать ширину кнопки шире, как в макете. Я использую его Среднюю статью , чтобы дать отправную точку.

Форма эмулятора

enter image description here

из макета

the mockup

мой код

private func setupUI() {
        navigationController?.navigationBar.prefersLargeTitles = true

        title = "Large Title"
        btnShare.setTitle("Share", for: .normal)
        // Initial setup for image for Large NavBar state since the the screen always has Large NavBar once it gets opened
        guard let navigationBar = self.navigationController?.navigationBar else { return }
        navigationBar.addSubview(btnShare)
        //btnShare.layer.cornerRadius = Const.UIButonSizeForLargeState / 2
        btnShare.clipsToBounds = true
        btnShare.translatesAutoresizingMaskIntoConstraints = false
        btnShare.backgroundColor = UIColor(red:0.00, green:0.48, blue:1.00, alpha:1.0)
        NSLayoutConstraint.activate([
            btnShare.rightAnchor.constraint(equalTo: navigationBar.rightAnchor, constant: -Const.UIButonRightMargin),
            btnShare.bottomAnchor.constraint(equalTo: navigationBar.bottomAnchor, constant: -Const.UIButonBottomMarginForLargeState),
            btnShare.heightAnchor.constraint(equalToConstant: Const.UIButonSizeForLargeState),
            btnShare.widthAnchor.constraint(equalTo: btnShare.heightAnchor)
            ])
    }




extension TransactionsTableViewController {
    /// WARNING: Change these constants according to your project's design
    private struct Const {
        /// Image height/width for Large NavBar state
        static let UIButonSizeForLargeState: CGFloat = 50
        /// Margin from right anchor of safe area to right anchor of Image
        static let UIButonRightMargin: CGFloat = 5
        /// Margin from bottom anchor of NavBar to bottom anchor of Image for Large NavBar state
        static let UIButonBottomMarginForLargeState: CGFloat = 12
        /// Margin from bottom anchor of NavBar to bottom anchor of Image for Small NavBar state
        static let UIButonBottomMarginForSmallState: CGFloat = 6
        /// Image height/width for Small NavBar state
        static let UIButonSizeForSmallState: CGFloat = 32
        /// Height of NavBar for Small state. Usually it's just 44
        static let NavBarHeightSmallState: CGFloat = 44
        /// Height of NavBar for Large state. Usually it's just 96.5 but if you have a custom font for the title, please make sure to edit this value since it changes the height for Large state of NavBar
        static let NavBarHeightLargeState: CGFloat = 96.5
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...