I tried to open two subviews and closed at time so I tried like this
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(event.type == UIEventSubtypeMotionShake)
{
[self shakeView];
//[self open];
}
}
-(void)shakeView
{
[UIView animateWithDuration:2.8
animations:^{
//OPEN
firstView.frame = CGRectMake(0, -40, self.view.frame.size.width, self.view.frame.size.height/2);
secondView.frame = CGRectMake(0, 260, self.view.frame.size.width, self.view.frame.size.height/2);
// Its final location
}
completion:^(BOOL finished) {
// Closed
firstView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height/2);
secondView.frame = CGRectMake(0,230 , self.view.frame.size.width, self.view.frame.size.height/2);
}
];
}
I need two view changed positions and then come to same positions, but when I call this two methods open slow but closed very fast.
How do I set timer when Closed views?
try this.
-(void)shakeView
{
[UIView animateWithDuration:2.8
animations:^{
//OPEN
firstView.frame =CGRectMake(0, -40, self.view.frame.size.width, self.view.frame.size.height/2);
secondView.frame =CGRectMake(0, 260, self.view.frame.size.width, self.view.frame.size.height/2);
// its final location
}
completion:^(BOOL finished)
{
//Closed
[UIView animateWithDuration:0.5 animations:^{
firstView.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height/2);
secondView.frame=CGRectMake(0,230 , self.view.frame.size.width, self.view.frame.size.height/2);
}];
}];}