Подтвердить что ты не робот

Настройка прозрачного фона для UILabel для приложения iphone

У меня есть UILabel в UITableView. Вот код, который я написал в cellForRowAtIndexPath

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(30.0, 5.0, 250.0, 35.0) reuseIdentifier:CellIdentifier] autorelease];
    }   


    CGRect rect = CGRectMake(30.0, 5.0, 250.0, 35.0);
    UILabel *label = [[UILabel alloc] initWithFrame:rect];

    label.opaque = NO;  
    label.font = [UIFont systemFontOfSize:14];
    label.numberOfLines = 2;
    label.textAlignment = UITextAlignmentCenter;            
    label.textColor = [UIColor darkGrayColor];
    label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
    [label setText:@"Test Message"];    

    [cell addSubview:label];
    [label release];
    cell.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;    

Мое намерение состояло в том, чтобы установить фон ячейки и UILabel как прозрачный.

Но он не работает. может кто-нибудь сказать мне, что я здесь отсутствует

Спасибо

Сандип

4b9b3361

Ответ 1

Измените следующую строку:

label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];

:

label.backgroundColor = [UIColor clearColor];

Ответ 2

Для тех, кто использует Xamarin.iOS, очевидно:

UILabel myLabel = new UILabel();
myLabel.Text = "Hello world!";
myLabel.BackgroundColor = UIColor.Clear;

Ответ 3

[label setBackGroundColor:[UIColor clearColor]];

Чтобы установить цвет clearBackGround для метки