0

我已将 UIView 添加到 IB 的另一个“主”视图中。我的应用程序仅处于横向模式。我想让它通过按下一个按钮,这个另一个 UIView 从底部滑入。所以,目前它根本不在图片中,但是当按下按钮时,视图会从底部出现并滑入到位。稍后我将使用相同的按钮作为切换按钮,然后将 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
4

1 回答 1

1

简单的视图动画:

- (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];
    }];
}
于 2012-09-22T15:39:22.357 回答