简体   繁体   English

Xcode InterfaceBuilder模拟了具有自定义高度的导航栏的指标

[英]Xcode InterfaceBuilder simulated metrics for navbar with custom height

I have a project where a custom height navigation bar is used across the app so it is 62px instead 44px tall. 我有一个项目,在整个应用程序中使用自定义高度导航栏,因此它是62px而不是44px高。 I am trying to build and layout my views using the storyboard editor (interface builder) although when using the Top Bar attribute set to Navigation Bar under the simulated metrics under the view controller options, this turns to be the default 44px one and not the custom height navbar (64px) I want. 我正在尝试使用故事板编辑器(界面构建器)构建和布局我的视图,尽管在视图控制器选项下使用模拟度量下的导航栏设置的顶栏设置属性时,这将变为默认的44像素而不是自定义高度导航栏(64px)我想要。

This way all the view work area shows up on a different size and I always need to calculate what is going to exceed or not. 这样,所有视图工作区都显示在不同的大小上,我总是需要计算将要超出的范围。

Is there any way that I can use both simulated metrics and a custom height navbar subclass gracefully while keeping the exact height I will have to work on the remaining space? 有没有什么方法可以优雅地使用模拟指标和自定义高度导航栏子类,同时保持我必须在剩余空间上工作的确切高度?

It is not possible to change the Simulated Metrics to custom values by Xcode. Xcode无法将模拟指标更改为自定义值。 A possibility is to design the custom navbar and copy it everywhere instead of the navigation, but then it is not simulated any longer. 一种可能性是设计自定义导航栏并将其复制到任何地方而不是导航,但之后不再模拟它。 Or you could make a little hack by going into 或者你可以通过进入一点点破解

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/PrivatePlugIns/IDEInterfaceBuilderCocoaTouchIntegration.ideplugin/Contents/Resources

and open CocoaTouchConstraints.plist In this file you can set the value of NavigationBar to the desired values. 并打开CocoaTouchConstraints.plist在此文件中,您可以将NavigationBar的值设置为所需的值。 So if you want a Navigation Bar that is 60 high just set Maximum and minimum height to 60: 因此,如果您想要一个60高的导航栏,只需将最大和最小高度设置为60:

<key>NavigationBar</key>
    <dict>
        <key>MaximumSize</key>
        <string>{10000, 60}</string>
        <key>MinimumSize</key>
        <string>{0, 60}</string>
    </dict>

After saving you need to restart Xcode and you NavigationBar will have the desired height. 保存后,您需要重新启动Xcode ,您的NavigationBar将具有所需的高度。

我担心你不能真的这样做,如果你想在Interface Building中直接有一个类似的行为和正确的自动布局和约束,为你的自定义导航栏类​​添加一个简单的视图,并使用正确的指标,(它会起作用)很好,因为导航栏继承自UIView)只需添加视图,设置自定义类,并为视图的导航栏和顶部对象添加约束。

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

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