Пользовательские ячейки iPhone - прозрачный фон этикетки - PullRequest
1 голос
/ 10 июня 2009

Картинка стоит больше тысячи слов:)

alt text

Вот код:


// Initialization code
        UIView *myContentView = self.contentView;
        UIImage *image = [UIImage imageNamed: @"bg_top.png"];
        UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
        self.backgroundView = imageview;
        [imageview release];
        self.label = [self newLabelWithPrimaryColor:[UIColor blackColor] selectedColor:[UIColor redColor] fontSize:15.0 bold:YES]; 
        self.label.textAlignment = UITextAlignmentLeft; 
        [myContentView addSubview:self.label];
        [self.label release];</p>

<pre><code>    self.textField = [[UITextField alloc] init];
    [self.textField setTextColor:[UIColor grayColor]];
    self.textField.font = [UIFont systemFontOfSize:13.0];
    //self.textField.secureTextEntry = YES;
    [self.textField setKeyboardType:UIKeyboardTypeEmailAddress];
    myContentView.backgroundColor = [UIColor clearColor];
    [myContentView addSubview:self.textField];
    [self.textField release];

Вопрос в том, как удалить этот уродливый белый фон с меток и сделать их прозрачными.

Ответы [ 3 ]

6 голосов
/ 10 июня 2009

Или альтернативно:

self.label.backgroundColor = [UIColor clearColor];
0 голосов
/ 11 июня 2009

Просто чтобы подвести итог. Основываясь на всех ваших ответах, лучшее решение:

[self.label setBackgroundColor:[UIColor clearColor]];
0 голосов
/ 10 июня 2009

Попробуйте установить цвет фона с помощью:

[self.label setBackgroundColor: [UIColor colorWithWhite: 1.0f alpha: 0.0f]];

или установите значение альфа 0

[self.label setAlpha: 0.0f];

Надеюсь, что сработает.

...