如何在横向模式下从底部滑动UIView
我已经添加了一个UIView到IB的另一个“主”视图。 我的应用程序仅处于横向模式。 我想这样做,通过按下button,这个其他UIView从底部滑入。 所以,目前它不在图片中,但是当按下button时,视图从底部出现并滑入到位。 稍后,我将使用与切换button相同的button,然后将UIVIew滑出。 UIView不是屏幕的大小,否则我会以模态方式呈现它。
这是我试过的代码:
.M
-(IBAction)onGearBag:(UIButton *)sender { [sender setEnabled:NO]; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ if (gearBag.transform.ty == 0) { [gearBag setTransform:CGAffineTransformMakeTranslation(0, -400)]; }else{ [gearBag setTransform:CGAffineTransformMakeTranslation(0, -200)]; } }completion:^(BOOL done){ //some completion handler [sender setEnabled:YES]; }]; }
。H
@interface MyEquipmentViewController : PFViewController { IBOutlet UIView *gearBag; } @property (strong, nonatomic) TabsTopBar *topbar; - (IBAction)onPopoverButton:(UIButton *)sender; - (IBAction)actionHelp:(id)sender; - (IBAction)onGearBag:(id)sender; @end
。H
@interface MyEquipmentViewController : PFViewController { IBOutlet UIView *popoverInitAlert; __unsafe_unretained IBOutlet UIImageView *imageView; IBOutlet UIView *gearBag; } @property (strong, nonatomic) TabsTopBar *topbar; - (IBAction)onPopoverButton:(UIButton *)sender; - (IBAction)actionHelp:(id)sender; - (IBAction)onGearBag:(id)sender; @end
简单的视图animation:
- (IBAction)myIBAction:(UIButton *)sender { [sender setEnabled:NO]; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ if (mySecondView.transform.ty == 0) { [mySecondView setTransform:CGAffineTransformMakeTranslation(0, -400)]; }else{ [mySecondView setTransform:CGAffineTransformMakeTranslation(0, 0)]; } }completion:^(BOOL done){ //some completion handler [sender setEnabled:YES]; }]; }