简体   繁体   English

滑动UIView以部分覆盖另一个UIView

[英]Sliding a UIView to partially overlay another UIView

It's been a couple of hours since I've been searching on how to do the animation as stated above. 自从我一直在寻找如何制作如上所述的动画以来已经过了几个小时。 So far, I've found this folding navigation by honcheng and it's quite cool. 到目前为止,我已经通过honcheng找到了这个折叠导航 ,这很酷。 However, what I want is a bit simpler than this. 但是,我想要的比这更简单。 The way the google map is being brought out from the right side, that's what I wish minus the flipping page effect. 谷歌地图从右侧出来的方式,这就是我希望减去翻页效果。 Somehow like the way Pulse news for iPad does which is also awesome. 不知何故,喜欢iPad的Pulse新闻的方式也很棒。

So yeah, if anyone has done this, can you suggest some ideas on how can I learn this. 所以,是的,如果有人这样做了,你能否提出一些关于如何学习这个的想法。 Or perhaps an open source which I could look on, and do reverse engineering instead. 或者也许是一个我可以看到的开源,并改为进行逆向工程。

This should help you, although keep in mind I'm not very familiar with the animations used in Pulse. 这应该对你有帮助,但请记住,我对Pulse中使用的动画不是很熟悉。

.h declare a UIView named secondView. .h声明一个名为secondView的UIView

- (void)viewDidLoad
{
    [super viewDidLoad];
    secondView = [[UIView alloc] initWithFrame:CGRectMake(320, 0, 320, 480)];
    [secondView setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:secondView];
}

- (IBAction)myAction:(id)sender
{
    [UIView animateWithDuration:0.45 animations:^{
        if (secondView.transform.tx == 0) {
            [secondView setTransform:CGAffineTransformMakeTranslation(-200, 0)];
        }else{
            [secondView setTransform:CGAffineTransformMakeTranslation(0, 0)];
        }

    }];
}

Then simply link this action to a button that won't be blocked by your new incoming view! 然后只需将此操作链接到一个不会被新的传入视图阻止的按钮!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM