Snail—UI学习之弹出按钮选择项UIActionSheet
来源:互联网 发布:云端软件 知乎 编辑:程序博客网 时间:2024/05/21 09:04
- (void)createButton{ UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectMake(10, 70, 300, 40); [button setTitle:@"分享" forState:UIControlStateNormal]; [button addTarget:self action:@selector(share) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; }- (void)share{ [self createActionSheet]; }- (void)createActionSheet{ UIActionSheet * sheet = [[UIActionSheet alloc] initWithTitle:@"分享" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"新浪微博" otherButtonTitles:@"腾讯",@"朋友圈",@"QQ好友", nil]; //sheet加到屏幕上 [sheet showInView:self.view];}- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ //buttonIndex从上往下 从0开始 跟alertView不太一样 switch (buttonIndex) { case 0:{ self.view.backgroundColor = [UIColor yellowColor]; NSLog(@"0"); } break; case 1: NSLog(@"1"); break; case 2: NSLog(@"2"); break; case 3: NSLog(@"3"); break; case 4: NSLog(@"4"); break; default: NSLog(@"hehe"); break; } }
效果图
0 0
- Snail—UI学习之弹出按钮选择项UIActionSheet
- Snail—UI学习之初识
- Snail—UI学习之UILabel
- Snail—UI学习之UIButton
- Snail—UI学习之动画Animations
- Snail—UI学习之UITextField
- Snail—UI学习之进度条UIProgressView
- Snail—UI学习之UISegmentControl
- Snail—UI学习之开关UISwith
- Snail—UI学习之工具栏UIToolBar
- Snail—UI学习之UITableView之分组显示
- Snail—UI学习之UITableView之自定义UITableViewCell
- Snail—UI学习之得到某组件的方法
- Snail—UI学习之UIImage及UIImageView
- Snail—UI学习之自定义通知NSNotification
- Snail—UI学习之导航视图控制器UINavigationController(系统)
- Snail—UI学习之自定义导航栏NSNavigationController
- Snail—UI学习之代理传值Delegate
- C语言——文件分类
- JQPAGINATION分页插件实践
- monoslam,scenelib,spcaview
- quick Cocos2d-x lua 八方向摇杆代码实现
- 数据结构之---C语言实现图的十字链表存储表示
- Snail—UI学习之弹出按钮选择项UIActionSheet
- [Cocoa]_[初级]_[NSTableView之自定义NSImageButtonCell]
- JavaScript replaceall 方法
- 聊天工具条
- hdoj1213 How many tables?(并查集)
- Java(07—29)学习总结
- 【交换安全】DAI - Dynamic ARP Inspection 详解
- source sh执行脚本的区别
- 2120 Ice_cream's world I