0

How do I add a button on window while using storyboards, I want the button to remain always visible on all screens.

I tried adding the image on the window but its not visible.

UIWindow *window =[UIApplication sharedApplication].delegate.window;
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
[img setBackgroundColor:[UIColor redColor]];
[window addSubview:img];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Diptesh
  • 383
  • 1
  • 5
  • 14

1 Answers1

1

I did not added a UIButton but have added a UIView to window in appdelegate.

Here you go:

UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window)
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];

svc = [[UIView alloc]initWithFrame(<some frame>)];
[[[window subviews] objectAtIndex:0] addSubview:svc];

Hope it helps

Vaibhav Saran
  • 12,848
  • 3
  • 65
  • 75