UIView прозрачность фона - PullRequest
       2

UIView прозрачность фона

0 голосов
/ 10 сентября 2011

Я добавляю UIView с фоновым изображением (которое имеет прозрачные части) в UITableViewCell.Сначала все выглядит идеально, но после отмены выбора строки фон моего UIView теряет прозрачность.

шаг 1

http://img29.imageshack.us/img29/1842/screenshot20110910at409.png

шаг 2

http://img41.imageshack.us/img41/1842/screenshot20110910at409.png

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

UIView *priceView = [[UIView alloc] init];
priceView.frame = CGRectMake(250, 10, 40, 21);

priceView.backgroundColor = [UIColor colorWithPatternImage:[ UIImage imageNamed:@"priceBG.png" ]];
priceView.opaque = NO;
[priceView.layer setOpaque:NO];
[cell addSubview:priceView];
[priceView release];
return cell;

Ответы [ 2 ]

0 голосов
/ 10 сентября 2011

Я не уверен, отвечаю ли я на ваш вопрос или нет, но чтобы установить фон tableViewCell, проверьте следующие свойства объекта tow.

  1. backgroundView
  2. selectedBackgroundView

Если вы не хотите задавать фон для ячейки, используйте UIImageView и установите его как subView в contentView, если ячейка.

Кажется, у вас проблема со стилем выбора ячеек. проверьте свойство selectionStyle здесь. Назначение правильного фона поможет вам удалить этот синий цвет.

Ниже приведена ссылка на ссылку на класс.

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html

0 голосов
/ 10 сентября 2011

Используйте взамен UIImageView и добавьте его в contentView ячейки:

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

UIImageView *priceImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"priceBG.png" ]];
priceImageView.frame = CGRectMake(250, 10, 40, 21);
priceImageView.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:priceImageView];
[priceImageView release];    
return cell;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...