I am using below code to show hide my subview:
[self.view addSubview:selectorView];
[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)];
viewVisible = NO;
- (IBAction)onButtonClick:(id)sender {
[self showHideView]; // Show and hide our imageView in an animated fashion}
- (void)showHideView {
if (viewVisible) { // If our imageView is on screen hide the view
[UIView beginAnimations:@"animateImageOff" context:NULL]; // Begin animation
[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)]; // Move imageView off screen
[UIView commitAnimations]; // End animations
viewVisible = NO;
[showHideButton setTitle:@"Show" forState:UIControlStateNormal]; // Change button title to "Show"
} else { // if our imageView is off screen show the view
[UIView beginAnimations:@"animateImageOn" context:NULL]; // Begin animation
[selectorView setFrame:CGRectOffset([selectorView frame], 0, selectorView.frame.size.height)]; // Move imageView on screen
[UIView commitAnimations]; // End animations
viewVisible = YES;
[showHideButton setTitle:@"Hide" forState:UIControlStateNormal]; // Change button title to "Hide"
}}
How can I set the subview Y-axis value in this code because when the subview gets on the screen it hides my screen header bar And I am using a button to show/hide the subview, I also want to animate that button so that when the button is clicked, button’s position should also be changed along Y-axis.
Here are the screenshots for what I want


Try to bring your your header view to front in the MainView:
And the image button animation you can do this: