0

这就是我的看法:

在此处输入图像描述

这就是我想要的样子(忽略文本颜色)

在此处输入图像描述

如您所见,应清除标题之间的视图。但这并没有发生。
这就是我实现模态 ViewController 的方式:

ActivityFilterViewController *filter = [[ActivityFilterViewController alloc] init];
    filter.view.backgroundColor = [UIColor clearColor];
    [filter setModalPresentationStyle:UIModalPresentationCurrentContext];
    [self presentViewController:filter animated:YES completion:nil];  

活动过滤器视图控制器

我已将其设置UITableView为分组并将部分的页眉和页脚的高度设置为 10。并且还清除了页眉视图的背景颜色。

4

5 回答 5

1

尝试这个:

viewDidLoad:

tableView.backgroundColor = [UIColor clearColor];

或以上不起作用,

tableView.backgroundView = nil;
于 2016-12-15T12:23:49.413 回答
0

使用自定义视图控制器。不是 ActivityController。随心所欲地设计它,并在当前上下文中呈现它。

不需要 UITableView ,因为您无论如何都不会滚动它。

只需为两个子视图使用圆角。

如果您可以在运行时隐藏一个按钮,您可以使用 UIStackView 以便布局会自动更改。

于 2016-05-30T06:36:13.327 回答
0

您可以将带有 a 的子视图添加UITableViewUIAlertController.

1创建 UIAlertController。

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                   message:nil
                                                            preferredStyle:UIAlertControllerStyleActionSheet];

2创建子视图UITableView

    UIVisualEffect *blurEffect;
    blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

    UIVisualEffectView *detailsView;
    //Let's match the cornerRadius the iOS Style
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
        detailsView = [[UIVisualEffectView alloc] initWithFrame:CGRectMake(0, -120, alertController.view.frame.size.width-20, 110)];
        detailsView.layer.cornerRadius = 15;
    } else {
        detailsView = [[UIVisualEffectView alloc] initWithFrame:CGRectMake(0, -120, alertController.view.frame.size.width-16, 110)];
        detailsView.layer.cornerRadius = 5;
    }

    detailsView.effect = blurEffect;
    detailsView.layer.masksToBounds = YES;
    detailsView.alpha = 1;
    detailsView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.74];

    //Add the UITableView
    UITableView *menuTableView = [[UITableView alloc]initWithFrame:detailsView.frame style:UITableViewStylePlain];
    [detailsView addSubview:menuTableView];

3添加动作和子视图并呈现UIAlertController

    UIAlertAction* resetAction = [UIAlertAction actionWithTitle:@"Reset to default"
                                                           style:UIAlertActionStyleDefault
                                                         handler:^(UIAlertAction * action){

    //Reset the switches in your UITableViewCells

    }];


    UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"Save"
                                                           style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction * action){

    //Save 

    }];

    [alertController addAction:resetAction];
    [alertController addAction:saveAction];

    // Add the Subview with the UITableView
    [alertController.view addSubview:detailsView];

    [self presentViewController:alertController animated:YES completion:nil];
于 2016-05-30T13:42:49.033 回答
0

其他人已经说过下面的步骤 1 和 2,但是为了我的回答的完整性,我还是要在这里说出来。

步骤 1,将表格视图背景设置为透明:

self.tableView.backgroundColor = [UIColor clearColor];

第 2 步,正如您所说,您必须通过覆盖heightForHeaderInSection方法来设置高度(在您的情况下为 10):

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 50.0;
}

第 3 步,通过覆盖viewForHeaderInSection方法提供自定义视图(注意- 这是您必须将背景颜色设置为清除的地方):

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.oTableView.frame.size.width, 10)];
    header.backgroundColor = [UIColor clearColor];

    return header;
}

第 4 步,一旦您确认这实际上是显示透明背景(您将在背景中看到此视图下方的视图,就像您在表格视图的上方和侧面看到的一样),然后您将专注于创建在单元格的顶部和底部产生您想要的效果。

您可以通过以下两种方式之一执行此操作:

  1. 修改您的UITableViewCell实现以创建圆角(如果部分中的第一个单元格,则仅左上角和右上角;如果部分中的最后一个单元格,则仅左下角和右下角)。
  2. 自定义您在覆盖中创建的自定义视图viewForHeaderInSection以提供圆角效果(将子视图添加到header您在此方法中返回的视图),但这会在顶部(第一个单元格)或顶部和底部(最后一个单元格)添加更多空间) 一节中的单元格。
于 2016-06-01T23:15:05.460 回答
0

如果ios version is lower then 8.0那么您应该将 modalpresentationstyle 设置为UIModalPresentationCurrentContextto self。就像是,

   self.modalPresentationStyle = UIModalPresentationCurrentContext;

如果您使用的是导航控制器,那么,

  self.nnavigationController.modalPresentationStyle = UIModalPresentationCurrentContext;

如果两个导​​航控制器到达这个视图那么,

 self.navigationController.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;

如果 ios 版本是,greater or equal to 8.0那么模态演示样式应该UIModalPresentationOverCurrentContext并且应该设置为您想要呈现的视图控制器,

  filter.modalPresentationStyle = UIModalPresentationOverCurrentContext;

如果您已进行此设置,请检查您的每一层的背景颜色是否设置为clear color过滤器 VC。

您应该调试视图层次结构以检查它们之间有多少层。

希望这会有所帮助:)

于 2016-05-27T12:46:44.970 回答