【问题标题】:Is it possible to add title to toolbar button, declared as UIBarButtonSystemItem是否可以将标题添加到工具栏按钮,声明为 UIBarButtonSystemItem
【发布时间】:2012-10-25 11:21:54
【问题描述】:

我想在我的导航工具栏中设置一些按钮,并且为了让用户不会对每个按钮的作用感到困惑,我想为每个按钮添加标题,显示在它下面。是否有可能做到这一点?

按钮声明:

UIBarButtonItem *changeFiltersButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshButton)] autorelease];

``...

[self setToolbarItems:[NSArray arrayWithObjects: flexible,
                           changeFiltersButton, flexible, flexible,
                           refreshFiltersList, flexible, flexible,
                           more, flexible, nil]];

【问题讨论】:

    标签: iphone xcode button toolbar title


    【解决方案1】:

    使用名称如以下示例的图像

        NSMutableArray *toolBaritems = [[NSMutableArray alloc] init];
    
        [toolBaritems addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]];
        [toolBaritems addObject:[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"img.png"] style:UIBarButtonItemStylePlain target:self action:@selector(refresh)]];
        [toolBaritems addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]];
        [toolBaritems addObject:[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"img2.png"] style:UIBarButtonItemStylePlain target:self action:@selector(change)]];
    
        [toolbar setItems:toolBaritems animated:NO];
    

    【讨论】:

    • 谢谢!所以我应该简单地创建一个带有文本的图像?这是有道理的......但如果不编辑整个图像,我将无法编辑标题:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多