0

方向モードのiPhoneマップアプリ(iOS 5の場合)では、ツールバーはナビゲーションバーのすぐ下にあり、ツールバーのグラデーションはナビゲーションバーの背景と完全に一致します。

同様の動作を実現する簡単な方法があるのでしょうか。(できればカスタム画像を使用せずに)

4

1 に答える 1

0

これは、ナビゲーションバーの下の画面上部にあるUIView(ツールバーにUIBarButtonItemとして追加された)内に2つのテキストフィールドがある通常のツールバーだと思います。

これが私がそれを実装した方法です:

    UIToolbar *bar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];

    UITextField *field1 = [[UITextField alloc] initWithFrame:CGRectMake(15, 5, 280, 30)];
    UITextField *field2 = [[UITextField alloc] initWithFrame:CGRectMake(15, 50, 280, 30)];
    [field1 setBorderStyle:UITextBorderStyleRoundedRect];
    [field2 setBorderStyle:UITextBorderStyleRoundedRect];

    UIView *viewForTextFields = [[UIView alloc] initWithFrame:bar.frame];

    [viewForTextFields addSubview:field1];
    [viewForTextFields addSubview:field2];

    UIBarButtonItem *viewForTextFieldsBarItem = [[UIBarButtonItem alloc] initWithCustomView:viewForTextFields];

    NSArray *items = [NSArray arrayWithObjects:viewForTextFieldsBarItem, nil];

    [bar setItems:items];
    [bar setContentMode:UIViewContentModeTopLeft];

    [self.view addSubview:bar];
于 2012-09-14T11:02:02.890 に答える