如何在横向模式下从底部在UIView中滑动 [英] How to slide in UIView from bottom in Landscape Mode

查看:72
本文介绍了如何在横向模式下从底部在UIView中滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将UIView添加到IB的另一个主视图中。我的应用程序仅在横向模式下。我想做到这一点,以便通过按下按钮,其他UIView从底部滑入。因此,当前它根本不在图片中,而是在按下按钮时,视图从底部出现并滑入到位。稍后,我将具有与切换相同的按钮,然后将UIVIew滑出。 UIView不是屏幕的大小,否则我会模态呈现它。

I have added a UIView to another 'main' view on IB. My application is in landscape mode only. I want to make it so that by pressing a button, this other UIView slides in from the bottom. So, currently it's not in the picture at all, but when the button is pressed, then the view appears from the bottom and slides into place. Later I will have the same button work as a toggle to then slide the UIVIew back out. The UIView is not the size of the screen, otherwise I would have presented it modally.

这是我尝试过的代码:

.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


推荐答案

简单视图动画:

- (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];
    }];
}

这篇关于如何在横向模式下从底部在UIView中滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆