首页 > 移动平台 > 详细

IOS学习之ActionSheet,传说中的popWindow;

时间:2015-04-25 18:22:37      阅读:175      评论:0      收藏:0      [点我收藏+]

这夏天来的太快,还没来的急去世界去看看,算了,在这看吧,每天的大白腿看的我也是心花怒放啊,看我的晚上无心撸码了。言归正传,必须得学习了,得像群里的大神看起了,什么(郭神了,泓洋神了,反正都是神),看见他们,我都觉得的自己。。。。。。这个控件使用频率比较高!

技术分享

好简单:

//
//  MyActionSheet.m
//  MyActionSheet
//
//  Created by xiaoyuan on 15/4/25.
//  Copyright (c) 2015年 xiaoyuan. All rights reserved.
//

#import "MyActionSheet.h"
#import "MBProgressHUD.h"

@interface MyActionSheet ()<UIActionSheetDelegate>

@end

@implementation MyActionSheet

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.barTintColor =[UIColor grayColor];
    [self.navigationController.navigationBar setTranslucent:YES];
    int width = self.view.frame.size.width;
    int height = self .view.frame.size.height;
    
    UIButton*btn =[[UIButton alloc] initWithFrame:CGRectMake(0, height/2, 50, 50)];
    //圆角
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
//    btn.frame = CGRectMake(0, 100, 100 , 100);
    [btn setTitle:@" fuck " forState:UIControlStateNormal];
    btn.backgroundColor =[UIColor greenColor];
    [btn addTarget:self action:@selector(fuck) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    CGPoint center = btn.center;
    center.x = self.view.center.x;
    btn.center = center;
    [btn sizeToFit];//包裹内容
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) fuck{
    UIActionSheet*sheet = [[UIActionSheet alloc]initWithTitle:@"请选择你的性格" delegate:self cancelButtonTitle:@"不许取消" destructiveButtonTitle:@"二逼" otherButtonTitles:@"逗比", nil];

    sheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [sheet showInView:self.view];
    

}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    switch (buttonIndex) {
        case 0:
            [self showToast:self msg:@"二逼"];
            break;
        case 1:
             [self showToast:self msg:@"逗逼"];
            break;
        case 2:
             [self showToast:self msg:@"傻逼"];
            break;
            
        default:
            break;
    }



}


-(void) showToast:(UIViewController *)vc msg:(NSString *)msg {
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:vc.navigationController.view animated:YES];
    
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.labelText = msg;
    //    hud.yOffset = vc.view.frame.size.height / 2;
    hud.removeFromSuperViewOnHide = YES;
    [hud sizeToFit];
    
    [hud hide:YES afterDelay:1.5];
}


@end
代码下载:

码农的路太长,但是我一定会好好努力!

IOS学习之ActionSheet,传说中的popWindow;

原文:http://blog.csdn.net/xiaoyuan511/article/details/45271445

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!