UINavigationBar + UISegmentedControl

//navigationBar通常只有左、右兩個按鈕,但可以
//通過添加UISegmentedControl來增加控制按鈕
UINavigationBar* _navBar;
UISegmentedControl* _SegCtl; 
 
_navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)];
[_navBar showButtonsWithLeftTitle: @"Done" rightTitle:NULL leftBack: TRUE];
[_navBar setBarStyle: 3];
[_navBar enableAnimation];
[_navBar setDelegate: self];
 
_SegCtl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(80.0f, 8.0f, 230.0f, 30.0f) withStyle:2 withItems:NULL];
[_SegCtl insertSegment:0 withTitle:@"Button one" animated:FALSE];
[_SegCtl insertSegment:1 withTitle:@"Button two" animated:FALSE];
[_SegCtl insertSegment:2 withTitle:@"Button three" animated:FALSE];
[_SegCtl setDelegate:self];
[_navBar addSubview:_SegCtl];
NSLog(@"navigation items is: %@", [_navBar navigationItems]);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章