我定製UISegmentedControl,但我有一個問題。如何自定義在iOS中UISegmentedControl?
如何在UISegmentedControl應用背景圖片?更改色調顏色不符合我的要求。
感謝
我定製UISegmentedControl,但我有一個問題。如何自定義在iOS中UISegmentedControl?
如何在UISegmentedControl應用背景圖片?更改色調顏色不符合我的要求。
感謝
我只是檢查,但似乎相當複雜。有沒有更簡單的解決方案? – user403015
如果你是一個註冊的蘋果開發者有可能對UISegmentedControl在iOS 5中的一些新的方法。 –
////Segmented Controll
NSArray *segmentTextContent = [NSArray arrayWithObjects: @"First",@"Second",@"Third",@"Forth", nil];
segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
segmentedControl.frame = CGRectMake(2, 5, 316, 35);
[segmentedControl addTarget:self action:@selector(segmentAction) forControlEvents:UIControlEventValueChanged];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.enabled = true;
segmentedControl.selectedSegmentIndex = 0;
// cutomize the font size inside segmentedControl
for (id segment in [segmentedControl subviews])
{
for (id label in [segment subviews])
{
if ([label isKindOfClass:[UILabel class]])
{
[label setTextAlignment:UITextAlignmentCenter];
[label setFont:[UIFont boldSystemFontOfSize:11]];
//[label setTextColor:[UIColor greenColor]];
}
}
}
這裏有幾個很好的替代品:http://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=segmented&commit=Search – Luke