1

写真は千の言葉よりも価値があります:)

代替テキスト

コードは次のとおりです。


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

問題は、ラベルから醜い白い背景を削除して透明にする方法です。

4

3 に答える 3

6

または、次のようにします。

self.label.backgroundColor = [UIColor clearColor];
于 2009-06-10T13:54:38.747 に答える
0

背景色を次のように設定してみてください。

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

またはアルファ値を 0 に設定します

[self.label setAlpha: 0.0f];

それがうまくいくことを願っています。

于 2009-06-10T13:13:05.680 に答える
0

物事を要約するだけです。すべての回答に基づいて、最善の解決策は次のとおりです。

[self.label setBackgroundColor:[UIColor clearColor]];
于 2009-06-11T06:49:40.873 に答える