【问题标题】:How do you hide a UIToolbar?如何隐藏 UIToolbar?
【发布时间】:2012-01-20 21:27:50
【问题描述】:

我在工具栏中有 2 个按钮。有没有办法隐藏工具栏并仍然显示 2 个按钮?这是目前为止的:

  UIBarButtonItem *cameraButton = [[UIBarButtonItem alloc] 
                                 initWithTitle:@"Camera"
                                 style:UIBarButtonItemStyleBordered
                                 target:self
                                 action:@selector(useCamera:)];
 /*    UIBarButtonItem *cameraRollButton = [[UIBarButtonItem alloc] 
                                     initWithTitle:@"Camera Roll"
                                     style:UIBarButtonItemStyleBordered
                                     target:self
                                     action:@selector(useCameraRoll:)]; */

NSArray *items = [NSArray arrayWithObjects: cameraButton,
                 /* cameraRollButton*/ nil];
[toolbar setItems:items animated:YES];

【问题讨论】:

    标签: ipad sdk ios5 xcode4.2


    【解决方案1】:

    这个问题不是很具体。您可以从其超级视图中删除工具栏。您可以将其不透明度设置为零。您可以将其框架设置为屏幕外。您可以为后两者设置动画。

    【讨论】:

    • 啊。我没试过。您可以尝试将 tintColor 设置为 [UIColor clearColor]。 iOS 5 增加了设置背景图片的功能。但 UIToolbars 往往具有渐变和/或边框效果,这些效果可能最终看起来很糟糕。
    猜你喜欢
    • 2011-02-27
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多