创建自定义UI栏按钮(从列表视图,网格视图更改视图)

时间:2013-09-03 13:58:07

标签: ios objective-c uitableview uibarbuttonitem

我正在尝试创建这样的ui bar按钮来更改视图。

enter image description here

但是,我不知道如何将2 ui bar buttom放在一起(1个方形按钮和4个方形按钮)。我只知道如何做这样的事情。我该怎么办?

enter image description here

1 个答案:

答案 0 :(得分:1)

UISegmentedControl而非UIButton

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] init];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"0.png"] atIndex:0 animated:NO];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"1.png"] atIndex:1 animated:NO];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
[[[self navigationController] navigationItem] setRightBarButtonItem:barButtonItem];