1

我用 catransition 做动画。我想单击一个按钮,然后从底部弹出我的视图层并覆盖屏幕。然后再次单击该按钮,我的视图层应该弹出到底部并消失。我的代码在下面。弹出功能工作正常。但弹出功能效果不佳。我的视图层刚刚消失并没有显示弹出操作。谁能告诉我该怎么做?多谢

#define HIDE_REG CGRectMake(0,372,0,0)
#define POPUP_REG CGRectMake(0,0,320,372)


- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    [otherText setFrame:HIDE_REG];
    isPopup = NO;

}



-(void)popup:(NSString *) content
{
        CATransition *animation = [CATransition animation];
        animation.delegate = self;
        animation.duration = 0.5f;
        animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        animation.fillMode = kCAFillModeForwards;
        animation.type = kCATransitionPush;
        animation.subtype = kCATransitionFromRight;
        [self.otherText.layer addAnimation:animation forKey:@"animation"];
        [self.otherText setFrame:POPUP_REG];
}


-(void)popdown:(NSString *) content
{
    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 0.5f;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    animation.fillMode = kCAFillModeForwards;
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromLeft;
    [self.otherText.layer addAnimation:animation forKey:@"animation"];
    [self.otherText setFrame:HIDE_REG];
}
4

0 回答 0