創建了一個view,在(0, 0, 320, 100)
位置顯示。現在我想讓這個view來自上一層,然後在給的位置設定。
試過:
CATransition *transition = [CATransition animation];
transition.duration = 1.0;
transition.type = kCATransitionFromTop; //choose your animation
[bGView.layer addAnimation:transition forKey:nil];
[self.view addSubview:bGView];
沒有成功。
可以i調整view的框架。先添加view作為subView
[self.view addSubview:bGView];
在屏幕可見范圍外加一個框架:
bGView.frame = CGRectMake(0,-150,320,100);
然後激活動畫,從上層處理:
[UIView animateWithDuration:2.0
animations:^{
bGView.frame = CGRectMake(0,0,320,100);
}
completion:^(BOOL finished){
;
}];