Keshav
Keshav

Reputation: 3273

how to add subview programmatically behind storyboard sub view

I have UIViewController which set top storyboard and having few subviews in storyboard. and I want to add a UIImageView programmatically and set it as a background view. so if I add a UIImageView, storyboard subviews are not visible.

how can I send this UIImageView behind all the storyboard subviews?

Thanks

Upvotes: 0

Views: 389

Answers (2)

Kumar KL
Kumar KL

Reputation: 15335

You need to go with the sendSubviewToBack:

 UIImageView *imgView = [[UIImageView alloc]initWithFrame:self.view.frame];
        imgView.image = [UIImage imageNamed:@"blank-background.jpg"];
        [self.view addSubview:imgView];
        [self.view sendSubviewToBack:imgView];

Upvotes: 2

shesh nath
shesh nath

Reputation: 26

use method of subview's "bringSubViewToFront". like

  [parentView bringSubViewToFront:subViewImg];

Upvotes: 0

Related Questions