zoukankan      html  css  js  c++  java
  • UIActionSheet

     

    #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=@"将要消失";

    }

  • 相关阅读:
    VB.NET中对象的克隆 利用了内存流内象和序列化
    关于对象组件编写的一点想法
    虽然有人说什么和平第一, 经济第一, 可是我怎么能不因为愤怒而发抖?
    用C# 调用MS speech引擎, 让电脑读文本, 或是存到WAV文件里去.
    抽空看了一下 dockpanel suite, 知道如何用了, 立此存照
    dn081A
    如何列出某类型的所有成员
    上周买了毛爷爷传
    【转载】MySQL双主双从高可用集群架构
    【转载】MySQL和Keepalived高可用双主复制
  • 原文地址:https://www.cnblogs.com/OIMM/p/4699124.html
Copyright © 2011-2022 走看看