following image describes the scenario. http://ift.tt/1KmNbUG
On animate button press, the blue screen (or containerView) should move away from view and similarly come back to initial position on repress.
The code is working. But the containerView is not behaving as the subview of some other view. It should not come out of light gray colored view. Which is its super view. It should move up and down within its limits.
The simulator screen shots are as follows :
Any suggestions are highly appreciated.
ViewController.m :-
@interface ViewController ()
{
BOOL scrollUp;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.containerBackgroundView addSubview:self.containerview];
scrollUp = NO;
[self animate:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)animate:(id)sender {
if (scrollUp) {
[self rollUpMenuPage];
scrollUp = NO;
}
else
{
scrollUp = YES;
[self unRollTheMenuPage];
}
}
-(void)unRollTheMenuPage
{
NSLog(@"containerview frame before unRoll : %@",[self.containerview description]);
CGRect rect = CGRectMake(self.containerview.frame.origin.x, 0.0f, self.containerview.frame.size.width, self.containerview.frame.size.height);
[UIView animateWithDuration:1.0f
animations:^{
self.containerview.frame = rect;
}
completion:^(BOOL finished){
// do something here if you wish.
NSLog(@"containerview frame after unRoll : %@",[self.containerview description]);
}];
}
-(void)rollUpMenuPage
{
NSLog(@"containerview frame before roll up : %@",[self.containerview description]);
CGRect rect = CGRectMake(self.containerview.frame.origin.x, -self.containerBackgroundView.frame.size.height, self.containerview.frame.size.width, self.containerview.frame.size.height);
[UIView animateWithDuration:1.0f
animations:^{
self.containerview.frame = rect;
}
completion:^(BOOL finished){
NSLog(@"containerview frame after roll up : %@",[self.containerview description]);
}];
}
ViewController.h
@property (weak, nonatomic) IBOutlet UIView *containerBackgroundView;
@property (weak, nonatomic) IBOutlet UIView *containerview;
Current output :- http://ift.tt/16eSDfp
Issue is, when moving up it should not go above the light gray colored view.
Thanks
Aucun commentaire:
Enregistrer un commentaire