简体   繁体   中英

Change height of toolbar

I have a toolbar with an added subview which has a height of 50. The subview is working perfectly but the toolbar cuts off the bottom of the view.

I have tried changing the frame with CGRectMake but this doesn't have any effect.

Here is the code:

var bannerAdView: FBAdView!


    override func viewDidAppear(animated: Bool) {
        super.viewWillAppear(false)

        self.navigationController?.setToolbarHidden(false, animated: true)
        bannerAdView = FBAdView(placementID: "bannerID", adSize: kFBAdSizeHeight50Banner, rootViewController: self)
        bannerAdView.delegate = self
        navigationController?.toolbar.addSubview(bannerAdView)
        navigationController?.toolbar.frame = CGRectMake(0,50,320,50)
        bannerAdView.loadAd()

    }

Edit: As Nate pointed out below, you can subclass UIToolbar and override the height to whatever custom height you want. That'd be cleaner than cloning it with a normal UIView, as you'd still get all the rest of the natural UIToolbar behaviors.

Original: unfortunately you're pretty much stuck with the typical UIToolbar height of 44.0px.

If I absolutely had to use something 50px high, I'd hide the actual toolbar and spoof it with a UIView that looks exactly like one. You might have some trouble emulating UIBarButtonItems with UIButtons, but if it's gotta be 50px high that's probably the quickest way for you to implement your UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM