YosiFZ
YosiFZ

Reputation: 7900

uiview with animation

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];

Upvotes: 0

Views: 583

Answers (2)

waterforest
waterforest

Reputation: 31

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

Upvotes: 1

tazboy
tazboy

Reputation: 1754

How about this:

addSubview animation

Upvotes: 0

Related Questions