0

我正在寻找将我的标准 UIToolbar(带有基于文本的按钮的不透明黑色)转换为更图形化的东西。可能类似于以下内容(取自 Blackberry 应用程序):

在此处输入图像描述

这会违反人机界面准则吗?我以前见过为 UITabbar 做过这种类型的定制,但从来没有为 UIToolbar 做过。如果我有一个执行基本 EDIT 任务的 EDIT 按钮,例如允许我删除表中的一行。如果我有像上面这样的自己的 EDIT 图形,Apple 会有什么感觉?

另外,与其创建自己的 UIToolbar 或子类化 UIToolbar 并对其进行修改以满足我的需要,我难道不能将一堆 UIButtons 与自定义图形并排排列成一个工具栏吗?

4

2 回答 2

1

苹果访问不会有任何问题,您不必继承任何东西,只需将其他组件放入工具栏:

-(UIToolbar *) toolBarActive {
if( _toolBarActive == nil ) {
    _toolBarActive = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 360, 320, 60)];
    [_toolBarActive setBackgroundImage:[UIImage imageNamed:@"image.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    _toolBarActive.tintColor = [UIColor blackColor];  
    [_toolBarActive setBackgroundColor:[UIColor blackColor]];
    UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    NSMutableArray *arrayItem = [[NSMutableArray alloc] init];
    [arrayItem addObject:flexibleSpace];
    [arrayItem addObject:self.buttonItem1];
    [arrayItem addObject:flexibleSpace];
    [arrayItem addObject:self.buttonItem2];
    [arrayItem addObject:flexibleSpace];
    [arrayItem addObject:self.buttonItem3];
    [arrayItem addObject:flexibleSpace];
    [arrayItem addObject:self.buttonItem4];
    [arrayItem addObject:flexibleSpace];
    [_toolBarActive setItems:arrayItem animated:YES];
}
return _toolBarActive;

}

例如 buttonItem1 定义为:

- (UIBarButtonItem *) buttonItem1 {
    if( _buttonItem1 == nil ) {
        _uttonItem1 = [[UIBarButtonItem alloc] initWithCustomView:self.button1];
        [_buttonItem1 setEnabled:YES];
        [_buttonItem1 setBackgroundVerticalPositionAdjustment:100.0f forBarMetrics:UIBarMetricsDefault];
    }
    return _buttonItem1;
}

和 button1 定义为:

 - (UIButton *) button1 {
    if( _button1 == nil ) {
        _button1 = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 50, 50)];
        [_button1 addTarget:self action:@selector(addNewImage) forControlEvents:UIControlEventTouchUpInside];
        [_button1 setImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
    }
    return _button1;
}
于 2012-10-30T15:16:57.580 回答
0

我认为您必须确保在定制时遵循苹果的准则。否则他们会拒绝。

您可以在此处查看工具栏指南 部分:Bars-->Toolbar

于 2012-10-30T15:12:08.267 回答