gpt4 book ai didi

iphone - navigationBar 中的左栏按钮项

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:53:40 24 4
gpt4 key购买 nike

在 iOS5 中,我们可以将 leftBarButtonItem 设置为导航栏,对于 iOS 5 之前的版本我该如何做?我基本上有一个 UIBarButtonItem 数组,我想将其设置为。

最佳答案

您可以建立自己的栏,并将其添加为左按钮:

    UIBarButtonItem *firstButton = [[UIBarButtonItem alloc] initWithTitle:@"First" style:UIBarButtonItemStyleBordered target:self action:@selector(firstButtonAction:)];
UIBarButtonItem *secondButton = [[UIBarButtonItem alloc] initWithTitle:@"Second" style:UIBarButtonItemStyleBordered target:self action:@selector(secondButtonAction:)];

UIToolbarTransparent *toolbar = [UIToolbarTransparent new];

[toolbar setFrame:CGRectMake(0,0, 140,44)];
[toolbar setItems:[NSArray arrayWithObjects:firstButton, secondButton, nil]];

UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc] initWithCustomView:toolbar];
self.navigationItem.leftBarButtonItem = customBarButton;

UIToolbar透明

.h

#import <Foundation/Foundation.h>

@interface UIToolbarTransparent : UIToolbar {

}

.m

#import "UIToolbarTransparent.h"

@implementation UIToolbarTransparent

- (id)init {
if (self = [super init]) {
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.translucent=YES;
}
return self;
}
@end

关于iphone - navigationBar 中的左栏按钮项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9557341/

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