博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

UISwitch用法

Posted on 2011-09-16 20:25  星尘的天空  阅读(331)  评论(0编辑  收藏  举报

LinK Address:http://blog.sina.com.cn/s/blog_63578f140100w3d2.html

1.UISwitch的初始化

 

1 UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(4.0f, 16.0f, 100.0f, 28.0f)];

 

2.设置UISwitch的初始化状态

 

1 switchView.on = YES;//设置初始为ON的一边

 

3.UISwitch事件的响应

 

1 [switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];

-(void) switchAction:(id)sender
   UISwitch * switch = (UISwitch *)sender;
}