2015-08-27 23 views
0

我有一個初始隱藏的UIView。我需要setHidden:NO(可視)具有下拉作用...UIView setHidden:NO like dropdown

有我的簡單的代碼,而不影響

-(IBAction)btnAbrirDestaquesClick:(id)sender { 
[self.viewDestaques setHidden:NO]; 
} 
+0

能詳細解釋一下,你可以告訴你的初始化self.viewDestques –

+0

你的觀點是如何在筆尖或您添加它編程 –

+0

我的觀點是在筆尖...我可以隱藏並顯示...但我需要顯示一個下拉菜單... –

回答

0

在iOS的7 UIDynamicAnimator一個更簡單的方法是春季動畫(新的強大的UIView塊動畫),它可以給你很好的彈跳效果與阻尼和速度:

[UIView animateWithDuration:duration 
    delay:delay 
    usingSpringWithDamping:damping 
    initialSpringVelocity:velocity 
    options:options animations:^{ 
    //Animations 
    [self.viewDestaques setHidden:NO]; 

    } 
    completion:^(BOOL finished) { 
    //Completion Block 
}]; 
+0

哪些動畫應該用於下拉效果? –

+0

使用UIViewAnimationOptionTransitionCurlDown –

0

如果你只是想製作動畫嘗試是這樣的:

[UIView animateWithDuration:.5 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
    self.viewDestaques.frame = CGRectMake(0, 0, 320,30); 
} completion:^(BOOL finished) { 

    [UIView animateWithDuration:.5 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
     self.viewDestaques.frame = CGRectMake(0, -30, 320,30); 

    } completion:^(BOOL finished) { 

    }]; 

}]; 
0

它的工作對我來說:

-(IBAction)btnAbrirDestaquesClick:(id)sender { 
[self.viewDestaques setTranslatesAutoresizingMaskIntoConstraints:YES]; //respeita o frame que eu setar, independentemente das constraints 

[self.viewDestaques setFrame:CGRectMake(self.viewDestaques.frame.origin.x, self.viewDestaques.frame.origin.y, self.viewDestaques.frame.size.width, 0)]; 

[self.viewDestaques setHidden:NO]; 

while (self.viewDestaques.frame.size.height < self.frameViewDestaquesOriginal.size.height) { 


    [UIView animateWithDuration:2.0 animations:^{ 
     [self.viewDestaques setFrame:CGRectMake(self.viewDestaques.frame.origin.x, self.viewDestaques.frame.origin.y, self.viewDestaques.frame.size.width, self.view.frame.size.height + 10)]; 
    }completion: ^(BOOL completed){ 
    }]; 

    } 
}