標籤:ios actionsheet 編程
這夏天來的太快,還沒來的急去世界去看看,算了,在這看吧,每天的大白腿看的我也是心花怒放啊,看我的晚上無心擼碼了。言歸正傳,必須得學習了,得像群裡的大神看起了,什麼(郭神了,泓洋神了,反正都是神),看見他們,我都覺得的自己。。。。。。這個控制項使用頻率比較高!
好簡單:
//// 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;