加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

UI类 - UIActionSheet的使用

(2013-04-25 18:11:46)
标签:

uiactionsheet

it

分类: Mac/IOS那些事
补充 :Button背景图片的平铺代码如下:
_doSomethingButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    _doSomethingButton.frame = CGRectMake(30, 280, 260, 30);
    _doSomethingButton.backgroundColor =[UIColor clearColor];
    //平铺图片
    UIImage *buttonImgNormal = [UIImage imageNamed:@"whiteButton"];
    UIImage *strectchableImgNormal = [buttonImgNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [_doSomethingButton setBackgroundImage:strectchableImgNormal forState:UIControlStateNormal];
    UIImage *buttonImgPress = [UIImage imageNamed:@"blueButton"];
    UIImage *strectchableImgPress=[buttonImgPress stretc

hableImageWithLeftCapWidth:12 topCapHeight:0];
    [_doSomethingButton setBackgroundImage:strectchableImgPress forState:UIControlStateHighlighted];
    [self.view addSubview:_doSomethingButton];
    [_doSomethingButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [_doSomethingButton setTitle:@"dosomthingbtn"forState:UIControlStateNormal];
   
在这个addTarget的基础上做一个uiActionsheet

-(void)buttonPressed:(id)sender{
    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"what do you want for?"
                                delegate:self
                                 cancelButtonTitle:@"no cancelTitle"
                                destructiveButtonTitle:@"no destructiontitle"
                               otherButtonTitles:@"other01",@"other02", nil];
    [actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        UIAlertView *alertYes = [[UIAlertView alloc]initWithTitle:@"alertYes"
                                 message:@"button0Yes"
                                delegate:self
                                cancelButtonTitle:@"doYesCancel"
                                 otherButtonTitles:nil, nil];
        [alertYes show];
    }else if (buttonIndex ==3) //other01 other02 的 buttonIndex是 1,2
    {
        UIAlertView *alertNo = [[UIAlertView alloc]initWithTitle:@"alertNo"
                          message:@"button1No" delegate:self
                          cancelButtonTitle:@"doNoCancel"
                        otherButtonTitles:nil, nil];
        [alertNo show];
    }
}
效果如图
http://s11/mw690/79fded95gdb2cbe77819a&690UIActionSheet的使用" TITLE="UI类 UIActionSheet的使用" />

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有