在UIPopoverController的页脚中使用UISegmentedControl

Fra*_*irs 10 iphone hig uisegmentedcontrol ipad uipopovercontroller

在我的iPad应用程序取景器(iTunes的链接),我试图重新创建一个UISegmentedControl的外观为基调的Build的页脚酥料饼看出:

基调

iPad HIG建议使用底部对齐的UIToolbar,但外观不正确.此屏幕截图显示Black Opaque,但没有一个标准样式与Keynote匹配.

取景器

任何有关重新创建Keynote外观的建议都将受到赞赏.如果您在iPad上没有Keynote,则可以在地图中的"书签"弹出窗口的页脚中看到相同的技巧.

her*_*mos 18

你需要做的是设置toolbarItems你的顶UIViewControllerUIPopover,并正确配置.考虑这样的事情:

        NSArray *segmentedItems = [NSArray arrayWithObjects:@"Bookmarks", @"Recents", @"Contacts", nil];
        UISegmentedControl *ctrl = [[UISegmentedControl alloc] initWithItems:segmentedItems];
        ctrl.segmentedControlStyle = UISegmentedControlStyleBar;
        ctrl.selectedSegmentIndex = 0;

        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:ctrl];
        ctrl.frame = CGRectMake(0.0f, 5.0f, 320.0f, 30.0f);

        NSArray *theToolbarItems = [NSArray arrayWithObjects:item, nil];
        [self setToolbarItems:theToolbarItems];
        [ctrl release]; 
        [item release];
Run Code Online (Sandbox Code Playgroud)

编辑:现在我明白了,只是不设置tintColor,它将继承正确的颜色(无论它是什么).现在,下面的屏幕截图与Google Maps App中的截图完全相同:

替代文字http://www.memorylifter.com/services/dev/linklist/SCREENSHOT_TABBAT.png

  • 要使其工作,您需要在`UIViewController`方法的`viewDidLoad`方法中添加`self.navigationController.toolbarHidden = NO;`(并且所讨论的`UIViewController`必须在`UINavigationController`中). (3认同)