如何获得一个类似于邮件应用程序中的 UISegmentedControl,以便它与 UIToolbar 按钮颜色相同(就好像两个段都处于选定状态一样)。
我想使用分段控件来实现与 Mail 完全相同的目的。
(在 iPad 上,所以是灰色而不是蓝色)
最佳答案
这是来自 Apple 示例代码的代码...导航栏以及代码中使用的两个图像.. 您应该能够获得与邮件应用程序完全相同的 View 。
// "Segmented" control to the right
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"up.png"],
[UIImage imageNamed:@"down.png"],
nil]];
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.frame = CGRectMake(0, 0, 90, 30);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.momentary = YES;
defaultTintColor = [segmentedControl.tintColor retain]; // keep track of this for later
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
[segmentedControl release];
self.navigationItem.rightBarButtonItem = segmentBarItem;
[segmentBarItem release];
关于iphone - 邮件应用程序中的 UISegmentedControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3772170/