调用view的animateWithDuration函数:
给出例子:
1/弹出选择框的动画:
-(void)popSelectView:(UIView *)view {
// 将选择列表加入到window
[self addSubview:view];
// 设置坐标
[view y_setLeft:0];
[view y_setTop:ScreenHeight];
[UIView animateWithDuration:0.3 animations:^{
[YUDarkGlassView share].alpha = 0.3 ;
view.frame = CGRectMake(0, ScreenHeight - view.frame.size.height, view.frame.size.width, view.frame.size.height);
}];
}
2、渐隐选择框
-(void)disMissPopSelectView{
[UIView animateWithDuration:0.3 animations:^{
[YUBottomPopSelctView share].frame = CGRectMake(0, ScreenHeight, [YUBottomPopSelctView share].frame.size.width, [YUBottomPopSelctView share].frame.size.height);
[YUDarkGlassView share].alpha = 0 ;
} completion:^(BOOL finished) {
[[YUDarkGlassView share] removeFromSuperview];
[[YUBottomPopSelctView share] removeFromSuperview];
}];
}
效果图: