0

i want to bring a view to my view controller with a little animation. some thing like the Facebook app.

i use this code to bring the uiview to the screen and i want to know how i can do it with little animation:

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];
YosiFZ
  • 7,792
  • 21
  • 114
  • 221

2 Answers2

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

How about this:

addSubview animation

Community
  • 1
  • 1
tazboy
  • 1,685
  • 5
  • 23
  • 39