Using a UISegmentedControl in the footer of UIPopoverController

后端 未结 3 523
野趣味
野趣味 2020-12-23 23:35

In my iPad app Viewfinder (iTunes Link), I\'m trying to recreate the look of a UISegmentedControl as seen in the footer of Keynote\'s Build In popover:

The

相关标签:
3条回答
  • 2020-12-24 00:02

    I just ran into this issue. You need to push a UINavigationController into the UIPopover. Your view should then be included in that navigation controller. This gets the top bar(navigation bar to format nicely). I would assume that the bottom bar follows this but I have not tested it!

    0 讨论(0)
  • 2020-12-24 00:11

    it looks like they are putting the segmented control in the footer view of the tableView. (first screenshot). I would try that if possible, else you could perhaps work on subclassing UIToolbar and overriding drawRect: to get the look you want.

    0 讨论(0)
  • 2020-12-24 00:29

    What you need is to set the toolbarItems of your top UIViewController in your UIPopover and configure it properly. Consider something like this:

            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];
    

    EDIT: Now i got it, just do not set the tintColor, it will inherit the correct color (whatever it is). The screenshot below now looks exactly like the one in the Google Maps App:

    alt text http://www.memorylifter.com/services/dev/linklist/SCREENSHOT_TABBAT.png

    0 讨论(0)
提交回复
热议问题