用动画观看

时间:2011-07-07 22:22:15

标签: iphone objective-c

我希望通过一点动画将视图带到我的视图控制器。 有点像Facebook应用程序。

我使用此代码将uiview带到屏幕上,我想知道如何用小动画做到这一点:

self.tmpView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 330)];  
self.tmpView.backgroundColor = [UIColor yellowColor];
UIImage *tmpImg = [UIImage imageNamed:@"d.png"];
UIImageView *tmpImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
tmpImgView.image = tmpImg;


UIButton *returnBTN = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
returnBTN.frame = CGRectMake(10, 110, 100, 25);
returnBTN.backgroundColor = [UIColor clearColor];
[returnBTN setTitle:@"חזור" forState:UIControlStateNormal];
[returnBTN addTarget:self action:@selector(backPressed) forControlEvents:UIControlEventTouchUpInside];


UIButton *orderBTN = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[orderBTN setTag:tag];
orderBTN.frame = CGRectMake(130, 110, 100, 25);
orderBTN.backgroundColor = [UIColor clearColor];
[orderBTN setTitle:@"הזמן" forState:UIControlStateNormal];
[orderBTN addTarget:self action:@selector(orderPressed:) forControlEvents:UIControlEventTouchUpInside];



[self.tmpView addSubview:tmpImgView];
[self.tmpView addSubview:returnBTN];
[self.tmpView addSubview:orderBTN];


[self.view addSubview:self.tmpView];

2 个答案:

答案 0 :(得分:1)

[UIView transitionFromView:viewToMoveOut toView:viewToMoveIn duration:timeOfDuration options:(option1 | option2 | ...) completion:^(BOOL finished){
    if (finished){
        // code when animation finished.
    }
}];

答案 1 :(得分:0)

这个怎么样:

addSubview animation