2009-06-10 25 views
1

图片的价值超过一千字:)iPhone定制的细胞 - 透明标签背景

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];

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]; 

的问题是如何从标签中移除丑陋的白色背景并使其透明。

+0

我们需要看到newLabelWithPrimaryColor:另外,您的内存管理看起来不正确。 – Eiko 2011-01-14 18:50:16

回答

0

尝试设置背景色:

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

或阿尔法值设置为0

[self.label setAlpha: 0.0f]; 

希望最后的伎俩。

+2

一个UIColor实例已经存在这样做:[self.label setBackgroundColor:[UIColor clearColor]]; – 2009-06-10 13:15:59

6

或者:

self.label.backgroundColor = [UIColor clearColor]; 
0

只是为了总结的东西了。根据您的所有回应,最佳解决方案是:

[self.label setBackgroundColor:[UIColor clearColor]];