#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UIActionSheetDelegate>

{

UILabel *lable;

}

@end

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];

button2.backgroundColor=[UIColor greenColor];

button2.frame=CGRectMake(100, 200, 120, 50);

[button2 addTarget:self action:@selector(showmyActionSheet:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button2];

}

-(void)showmyActionSheet:(UIButton *)sender

{

UIActionSheet *actionSheet1=[[UIActionSheet alloc]initWithTitle:@"ActionSheet" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"red color" otherButtonTitles:@"blue color",@"black color", nil];

NSLog(@"%@",[actionSheet1 buttonTitleAtIndex:0]);

[actionSheet1 showInView:self.view];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

if (buttonIndex==0) {

self.view.backgroundColor=[UIColor redColor];

}

else if (buttonIndex==1){

self.view.backgroundColor=[UIColor blueColor];

}

else if (buttonIndex==2)

{

self.view.backgroundColor=[UIColor blackColor];

}

}

//ActionSheet已经消失的方法

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

{

lable.text=@"已经消失";

}

//

- (void)actionSheetCancel:(UIActionSheet *)actionSheet{

lable.text=@"zheshism";

}

//将要出现

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet{

lable.text=@"将要出现";

}

//已经出现

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet{

lable.text=@"已经出现";

}

//将要消失

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{

lable.text=@"将要消失";

}

UIActionSheet的更多相关文章

  1. 弹框控件 UIAlertView UIActionSheet

    // 创建弹框 从底部弹出,一般用于危险操作 UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"恭喜通关" ...

  2. UI第十三节——UIActionSheet

    - (void)viewDidLoad {    [super viewDidLoad];        UISwitch *swc = [[UISwitch alloc] initWithFrame ...

  3. 【代码笔记】iOS-清除图片缓存UIActionSheet

    一,效果图. 二,代码. RootViewController.m //点击任何处出现sheet -(void)touchesBegan:(NSSet *)touches withEvent:(UIE ...

  4. UIAlertView 与 UIActionSheet (提示用户)的使用方法

    UIAlertView 提示用户  帮助用户选择框 //    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警 ...

  5. UI里的UIActionSheet按钮

    1.效果图:分别为有短信分享                                      无短信分享 -(void)viewDidLoad{ //添加按钮 UIButton *share ...

  6. UIActionSheet的使用

    UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view applicatio ...

  7. UIAlertView、 UIActionSheet

    一.UIAlertView. UIActionSheet都是ios系统自带的弹出式对话框,当UIAlertView或UIActionSheet弹出来时用户无法与应用界面中的其它控件交互,UIAlert ...

  8. IOS笔记之UIKit_UIAlertView、UIActionSheet

    //首先必须继承协议 @interface TRViewController : UIViewController<UIAlertViewDelegate,UIActionSheetDelega ...

  9. UIActionSheet 修改字体颜色

    -(void)willPresentActionSheet:(UIActionSheet *)actionSheet { SEL selector = NSSelectorFromString(@&q ...

  10. 封装同步的UIActionSheet

    封装同步的UIActionSheet 发问题 做 iOS 开发的同学想必都用过 UIActionSheet.UIActionSheet 可以弹出一个选择列表,让用户选择列表中的某一项操作.使用 UIA ...

随机推荐

  1. mysqldump dump-slave

    http://blog.itpub.net/29254281/viewspace-1392757/ 查看从库的状态,发现从库的sql_thread进程会自动停止,停止之后 又会自动开启,没有人操作这个 ...

  2. c# 计算两日期的工作时间间隔(排除非工作日)及计算下一个工作时间点.

    一个日期段如工作时间为 8:00 至 17:00 public class TimeHelper { /// <summary> /// 计算时间间隔 /// </summary&g ...

  3. centos复制到另外一台电脑连不上网

    http://snow-berry.iteye.com/blog/1991754 从一台电脑virtual box克隆出来的centos.vdi复制到另外一台电脑,找不到网卡,提示Device eth ...

  4. 将一副图片编译进uboot

    在uboot显示图片的时候可以将jpg图片作为uboot的一段,在程序中访问该段,实现图片. 图片: logo.jpg ,将其拷贝到common下 修改u-boot.lds,添加".log& ...

  5. Android设置窗口、控件透明度

    设置透明效果的方法如下: 1.在布局文中设置透明效果 android:background="@android:color/transparent" (通过android自带颜色设 ...

  6. js的Touch事件

    js的touch事件,一般用于移动端的触屏滑动$(function(){document.addEventListener("touchmove", _touch, false); ...

  7. 【Android 界面效果45】ViewPager源码分析

    ViewPager概述: Layout manager that allows the user to flip left and right through pages of data. You s ...

  8. 【Android 界面效果26】listview android:cacheColorHint,android:listSelector属性作用

    ListView是常用的显示控件,默认背景是和系统窗口一样的透明色,如果给ListView加上背景图片,或者背景颜色时,滚动时listView会黑掉, 原因是,滚动时,列表里面的view重绘时,用的依 ...

  9. 重构21-Collapse Hierarchy(去掉层级)

    我们通过提取子类来下放职责.,当我们意识到不再需要某个子类时,可以使用Collapse Hierarchy重构.如果某个子类的属性(以及其他成员)可以被合并到基类中,这时再保留这个子类已经没有任何意义 ...

  10. flexpaper 在线观看 PPT,PDF,DOC等文档

    0.安装环境.可以参考http://www.cnblogs.com/star-studio/archive/2011/12/09/2281807.html     百度关键字 仿百度文库方案 1.借用 ...