本文主要是介绍IOS学习之ActionSheet,传说中的popWindow(三),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
这夏天来的太快,还没来的急去世界去看看,算了,在这看吧,每天的大白腿看的我也是心花怒放啊,看我的晚上无心撸码了。言归正传,必须得学习了,得像群里的大神看起了,什么(郭神了,泓洋神了,反正都是神),看见他们,我都觉得的自己。。。。。。这个控件使用频率比较高!
好简单:
//
// 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 downhud.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(三)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!