gpt4 book ai didi

cocoa-touch - 在 Cocoa Touch 中更改其内部的 NavigationBar 和 UIBarButtonItem 元素的高度

转载 作者:行者123 更新时间:2023-12-02 14:11:31 26 4
gpt4 key购买 nike

我认为这并不严格符合苹果的指导方针,但我想这一定是可能的。我想更改 UINavigationController 内导航栏的高度和该栏中 UIBarButtonItem 元素的高度。

使用 this question 中的技巧我设法更改导航栏的高度,但我看不到调整栏按钮项目高度的方法。

如果有人知道如何更改栏按钮项目的大小,请帮助我。

最佳答案

这是我的解决方案。效果非常好。

@interface UINavigationBar (CustomHeight)

@end

@implementation UINavigationBar (CustomHeight)

- (CGSize)sizeThatFits:(CGSize)size {
// Change navigation bar height. The height must be even, otherwise there will be a white line above the navigation bar.
CGSize newSize = CGSizeMake(self.frame.size.width, 40);
return newSize;
}

-(void)layoutSubviews {
[super layoutSubviews];

// Make items on navigation bar vertically centered.
int i = 0;
for (UIView *view in self.subviews) {
NSLog(@"%i. %@", i, [view description]);
i++;
if (i == 0)
continue;
float centerY = self.bounds.size.height / 2.0f;
CGPoint center = view.center;
center.y = centerY;
view.center = center;
}
}

关于cocoa-touch - 在 Cocoa Touch 中更改其内部的 NavigationBar 和 UIBarButtonItem 元素的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8285728/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com