views:

44

answers:

3

I am trying to change the UILabel background color with this code

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];


    m_ShopName.text = m_CurrShop.m_Name;
    m_ShopAddress.layer.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0].CGColor; 
}

but nothing happend?

help!!

A: 

Can you do this:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];


    m_ShopName.text = m_CurrShop.m_Name;
    m_ShopAddress.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; 
}
Rob Fonseca-Ensor
A: 

I always did the following

m_ShopAddress.backgroundColor = [UIColor red];

When I wanted to change the alpha...

m_ShopAddress.alpha = 0.0f;

mj_
A: 

An alpha value of 0 means, it's fully transparent. That's probably why nothings happens (whatever you mean by that).

And I wouldn't access the background color of the layer, but of the UILabel directly.

Codo