0

これは私のビューがどのように見えるかです:

ここに画像の説明を入力

そして、これが私が望む方法です(テキストの色を無視します)

ここに画像の説明を入力

ご覧のとおり、ヘッダー間のビューをクリアする必要があります。しかし、それは起こっていません。
これは私がモーダル ViewController を実装する方法です:

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

ActivityFilterViewController :

グループとして設定しUITableView、セクションのヘッダーとフッターの高さを 10 に設定しました。また、ヘッダー ビューの背景色をクリアしました。

4

5 に答える 5

0

以下のステップ 1 と 2 は既に他の人が言っていますが、私の答えを完全にするために、とにかくここで言います。

ステップ 1、テーブル ビューの背景を透明に設定します。

self.tableView.backgroundColor = [UIColor clearColor];

ステップ 2、既に述べたように、メソッドをオーバーライドして高さを設定する必要がありますheightForHeaderInSection(この場合は 10):

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

ステップ 3viewForHeaderInSectionで、メソッドをオーバーライドしてカスタム ビューを提供します(- ここで、背景色をクリアに設定する必要があります)。

- (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で、これが実際に透明な背景を表示していることを確認したら (表ビューの上と側面に表示されているのと同じように、この下のビューが背景に表示されます)、次に、セルの上部と下部に必要な効果。

これは、次の 2 つの方法のいずれかで実行できます。

  1. 実装を変更UITableViewCellして角を丸くします (セクションの最初のセルの場合は左上と右上のみ、セクションの最後のセルの場合は左下と右下のみ)。
  2. オーバーライドで作成しているカスタム ビューをカスタマイズして、viewForHeaderInSection角の丸い効果を提供します (headerこのメソッドで返されるビューにサブビューを追加します)。ただし、上部 (最初のセル) または上下 (最後のセル) にスペースが追加されます) セクション内のセルの。
于 2016-06-01T23:15:05.460 に答える
0

UITableViewを持つサブビューを に追加できますUIAlertController

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

その場合ios version is lower then 8.0は、モーダル表示スタイルをUIModalPresentationCurrentContextに設定する必要がありますself。何かのようなもの、

   self.modalPresentationStyle = UIModalPresentationCurrentContext;

ナビゲーションコントローラーを使用している場合は、

  self.nnavigationController.modalPresentationStyle = UIModalPresentationCurrentContext;

2 つのナビゲーション コントローラーがこのビューに到達する場合、

 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 に答える