我正在尝试从另一个视图控制器呈现一个视图控制器,它可以工作,但是呈现的控制器有黑色背景,我希望它清晰。
- (void)showMenu
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
MenuTableViewController *menu = [[MenuTableViewController alloc]initWithNibName:@"MenuTableViewController" bundle:nil];
menu.view.backgroundColor = [UIColor clearColor];
menu.modalPresentationStyle = UIModalPresentationCurrentContext;
blurredView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[blurredView setBarStyle:UIBarStyleBlack];
[self.view addSubview:blurredView];
[self presentViewController:menu animated:YES completion:nil];
}
MenuTableViewController.h
import <UIKit/UIKit.h>
@interface MenuTableViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@end
MenuTableViewController.m
@interface MenuTableViewController ()
@end
@implementation MenuTableViewController
{
NSMutableArray *menuItems;
NSMutableArray *insuranceItems;
}
- (void)viewDidLoad
{
[super viewDidLoad];
menuItems = [NSMutableArray arrayWithObjects:@"Action Alerts", @"Ag News", @"Market Updates", @"Tours & Conferences", @"KFB Magazine", @"Member Benefits", @"Ag Facts", @"Roadside Farm Markets", @"Weather", @"Annual Meeting", @"Media", nil];
insuranceItems = [NSMutableArray arrayWithObjects:@"My KYFB", nil];
self.view.backgroundColor = [UIColor clearColor];
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0)
{
return @"Federation";
}
else
{
return @"Insurance";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
{
return menuItems.count;
}
else
{
return insuranceItems.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *mbTableIdentifier = @"SimpleTableItem";
// UIColor *kfbBlue = [UIColor colorWithRed:8.0/255.0f green:77.0/255.0f blue:139.0/255.0f alpha:1];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mbTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:mbTableIdentifier];
cell.textLabel.font=[UIFont systemFontOfSize:16.0];
}
cell.textLabel.font = [UIFont fontWithName:@"FranklinGothicStd-ExtraCond" size:24.0];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.textLabel.textColor = [UIColor whiteColor];
cell.backgroundColor = [UIColor clearColor];
if (indexPath.section == 0)
{
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
}
else
{
cell.textLabel.text = [insuranceItems objectAtIndex:indexPath.row];
}
return cell;
}