简体   繁体   English

更改工具栏的高度

[英]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. 我有一个带有添加的子视图的工具栏,该子视图的高度为50。该子视图工作正常,但是工具栏切掉了视图的底部。

I have tried changing the frame with CGRectMake but this doesn't have any effect. 我尝试使用CGRectMake更改框架,但这没有任何效果。

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. 编辑:正如Nate在下面指出的那样,您可以将UIToolbar子类化,并将高度覆盖到所需的任何自定义高度。 That'd be cleaner than cloning it with a normal UIView, as you'd still get all the rest of the natural UIToolbar behaviors. 这将比使用普通的UIView克隆它干净,因为您仍然可以获得其余的自然UIToolbar行为。

Original: unfortunately you're pretty much stuck with the typical UIToolbar height of 44.0px. 原始文件:不幸的是,您几乎陷于44.0px的典型UIToolbar高度。

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. 如果我绝对必须使用50px高的东西,我将隐藏实际的工具栏,并使用看起来像一个的UIView对其进行欺骗。 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. 您可能在使用UIButtons模拟UIBarButtonItems时会遇到一些麻烦,但是如果它必须高到50px,那可能是实现UI的最快方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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