Белая линия через UIToolbar, когда присутствует табличное представление - PullRequest
0 голосов
/ 02 декабря 2009

У меня есть программно созданный UIToolbar в нескольких видах. На мой взгляд, у которой есть таблица, в центре панели инструментов есть белая линия, которая выглядит там, где будет граница ячейки таблицы. Есть ли способ избавиться от этой линии?

Вот снимок экрана:

iphone table with white bar

Вот код, который я использую для создания показанной панели инструментов:

- (void) createToolbarItems {
UIBarButtonItemStyle style = UIBarButtonItemStylePlain;

UIImage *addWishImg = [UIImage imageNamed:@"btn-addwish-off.png"];
UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[addBtn setImage:addWishImg forState:UIControlStateNormal];
addBtn.frame = CGRectMake(0, 0, addWishImg.size.width, addWishImg.size.height);
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithCustomView:addBtn];
[addButton setTarget:self];
[addButton setAction:@selector(addWish)];
addButton.style = style;

UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
                                                                          target:nil
                                                                          action:nil];
flexItem.style = style;

UIImage *emailImg = [UIImage imageNamed:@"btn-mail-off.png"];
UIButton *emailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[emailBtn setImage:emailImg forState:UIControlStateNormal];
emailBtn.frame = CGRectMake(0, 0, emailImg.size.width, emailImg.size.height);
UIBarButtonItem *emailButton = [[UIBarButtonItem alloc] initWithCustomView:emailBtn];
[emailButton setTarget:self];
[emailButton setAction:@selector(addWish)];
emailButton.style = style;

NSArray *items = [NSArray arrayWithObjects: addButton, flexItem, emailButton, nil];
[self.toolbar setItems:items animated:NO];

[addButton release];
[flexItem release];
[emailButton release];

}

- (void)viewDidLoad {
[super viewDidLoad];

…

// create the UIToolbar at the bottom of the view controller
toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlackOpaque;

// size up the toolbar and set its frame
[toolbar sizeToFit];
CGFloat toolbarHeight = [toolbar frame].size.height;
NSLog(@"%f", toolbarHeight);
CGRect mainViewBounds = self.view.bounds;
[toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),
                             CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight * 2.0) + 2.0,
                             CGRectGetWidth(mainViewBounds),
                             toolbarHeight)];

[self.view addSubview:toolbar];

[self createToolbarItems];

}

Ответы [ 2 ]

1 голос
/ 02 декабря 2009

Вы проверяли, перекрывает ли ваш tableView панель инструментов? В противном случае не вижу никаких явных проблем. Установите цвет фона для вашей таблицы, чтобы увидеть, если это так. Или просто немного уменьшите высоту таблицы, чтобы увидеть, решит ли это проблему

0 голосов
/ 21 января 2010

Установка стиля разделителя таблицы на None избавляет от этой проблемы.

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone
...