This is because you are covering the entire view in your rectangle. You have to subtract the height and width of the tab and navigation bar.
take a look at this example
- (void)viewDidLoad { [super viewDidLoad]; CGFloat viewheight = self.view.frame.size.height; CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height; CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height; CGFloat spaceToRemove = navBarHeight + tabBarHeight; CGFloat newHeight = viewheight - spaceToRemove; NSLog(@"%f",newHeight); NSLog(@"%f",self.view.frame.size.height); CGRect frame = CGRectMake(0 , 0 + navBarHeight, self.view.frame.size.width, newHeight); UIView *newView = [[UIView alloc]initWithFrame:frame]; newView.backgroundColor = [UIColor redColor]; [self.view addSubview:newView]; }
user4254887
source share