-
IOSSegmentedControl(添加到Nav上)的简单使用方法
- /* 初始化导航按钮 */
- {
- credits = [ [ [ UIBarButtonItem alloc ]
- initWithTitle:@"Credits"
- style: UIBarButtonItemStylePlain
- target: appDelegate
- action:@selector(credits) ]
- autorelease ];
- self.navigationItem.rightBarButtonItem = credits;
-
- segmentedControl = [ [ UISegmentedControl
alloc ] initWithItems: nil ];
- segmentedControl.segmentedControlStyle =
UISegmentedControlStyleBar;
-
- [ segmentedControl insertSegmentWithTitle:
@"Bunnies" atIndex: 0
- animated: NO
- ];
- [ segmentedControl insertSegmentWithTitle:
@"Ponies" atIndex: 1
- animated: NO
- ];
-
- [ segmentedControl addTarget: self action:
@selector(controlPressed:)
- forControlEvents:UIControlEventValueChanged
- ];
-
- self.navigationItem.titleView = segmentedControl;
- segmentedControl.selectedSegmentIndex = 0;
- }
- return self;
- }
-
- - (void)controlPressed:(id) sender {
- [ self setPage ];
- }
-
- - (void)setPage {
- int index = segmentedControl.selectedSegmentIndex;
-
- if (index == 0) {
- textView.text = @"OMG Bunnies!";
- } else {
- textView.text = @"OMG Ponies";
- }
- }
-
相关阅读:
前端
小程序开发
mpvue开发小程序
(33)Vue购物车
Vue的使用你学会了吗?
(32)Vue模板语法
(31)Vue安装
(3)Angular的开发
(2)Angular的开发
(1)Angular的开发
-
原文地址:https://www.cnblogs.com/tx8899/p/2537078.html
Copyright © 2020-2023
润新知