tags:

views:

71

answers:

3

the view generates an image at runtime. i didnt use the iB to create it. when i try a place a label over it ,The label contents dont show up.. here's my code

- (void)viewWillAppear:(BOOL)animated {
    UILabel *Label=[[UILabel alloc]initWithFrame:CGRectMake(0.0, 50.0, 150.0, 20.0)];

    Label.font=[UIFont fontWithName:@"Helvetica"  size:15];
    Label.text=@"sdvdssdvsdv";
    [self.view addSubview:Label];


    UIImageView *Headbar=[[UIImageView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 80.0)];
    Headbar.image=[UIImage imageNamed:@"header.jpg"];
    Headbar.opaque=YES;
    self.header=Headbar;    
    [Headbar release];
    [self.view addSubview:header]; 

    [super viewWillAppear:animated];
}

when i change the frame to CGRectMake(0.0, 80.0, 150.0, 20.0) it shows up.. but i need it on the image.. please help me out..

+2  A: 

looks like you're adding header after the label so it's covering it up. try changing the order.

move

[self.view addSubview:Label];

so it is after

[self.view addSubview:header]; 
PeanutPower
i figured it out.. if i add the label as a subview to the header it works fine.. [header addSubview:Label];thanks for your help..
akshay
+2  A: 

Switch the order to -addSubview: the two UI elements. The view added the last will be shown on the top.

Or use -insertSubview:aboveSubview:.

KennyTM
+1  A: 

Try to use the following two functions over the self.view:

- (void)bringSubviewToFront:(UIView *)view
- (void)sendSubviewToBack:(UIView *)view

Edited

It seems to me that you are trying to create a custom navigation with the image as a background and the label on top.

This is not the good way to get your thing done. I suggest you to ask a new question if this is what you want.

sfa
i'm not trying to create custom nav bar. The label and the image are meant to be a part of the content of the view. i just figured it out.if i add this i get the desired result.. thanks for your help... [header addSubview:Label];
akshay