UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
message:@"\n\n\n\n\n\n\n\n\n\n\n"// change UIAlertController height
preferredStyle:UIAlertControllerStyleActionSheet];
//Make a frame for the picker & then create the picker
CGRect pickerFrame = CGRectMake(12, 12, 270, 250);
picker.frame = pickerFrame;
ios8Picker = picker;
NSLog(@"%ld",(long)ios8Picker.tag);
//set the pickers selection indicator to true so that the user will now which one that they are chosing
[picker setShowsSelectionIndicator:YES];
//Add the picker to the alert controller
[alert.view addSubview:picker];
//make the toolbar view
UIToolbar *toolView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, alert.view.frame.size.width-16, kToolBarHeight)];
toolView.backgroundColor = [UIColor blackColor]; //set it's background
toolView.barStyle = UIBarStyleBlackTranslucent;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, kToolBarHeight)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont systemFontOfSize:14];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
// titleLabel.text = title;
UIBarButtonItem *bbtTitle = [[UIBarButtonItem alloc] initWithCustomView:titleLabel];
UIBarButtonItem *bbtSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *bbtOK = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStyleDone target:self action:@selector(OKWithPicker)];
bbtOK.width = 60.f;
UIBarButtonItem *bbtCancel = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(CancleWithPicker)];
bbtCancel.width = 60.f;
toolView.items = [NSArray arrayWithObjects:bbtCancel,bbtSpace,bbtTitle,bbtSpace,bbtOK, nil];
[alert.view addSubview:toolView];
[self presentViewController:alert animated:NO completion:nil];
}
UIActionSheet在IOS8上失效
最新推荐文章于 2017-05-20 22:01:00 发布