gpt4 book ai didi

ios - 如何为 UIToolbar 添加标题?

转载 作者:行者123 更新时间:2023-11-29 05:05:50 25 4
gpt4 key购买 nike

请我刚刚在我的 View 中添加了一个带有后退按钮的 UIToolbar ,我想为此 UIToolbar 添加一个标题,在界面生成器中我无法手动执行此操作,所以我应该将其添加到程序中,应该如何添加我愿意,我的 View 类是这样的:

#import "AproposView.h"


@implementation AproposView

-(IBAction)backMainView{


[self dismissModalViewControllerAnimated:YES];

}

这个后退按钮位于 UItoolbar 中,所以我只需要添加一个标题,提前谢谢:)

最佳答案

#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 202, 23)];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.shadowColor = UIColorFromRGB(0xe5e7eb);
// label.shadowOffset = CGSizeMake(0, 1);
label.textColor = UIColorFromRGB(0x717880);
label.text = @"Edit Classes";
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
label.shadowOffset = CGSizeMake(0, -1.0);
UIBarButtonItem *toolBarTitle = [[UIBarButtonItem alloc] initWithCustomView:label];
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
toolBar.items = [NSArray arrayWithObjects:fixedSpace, toolBarTitle, fixedSpace, nil];

关于ios - 如何为 UIToolbar 添加标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5326072/

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