UIView を iPhone, iPadの真ん中まで移動させる方法のメモです。
(iOS 5 で試してます。)
アニメーションは、UIViewの animationWithDuration を使います。画面の中心座標は、self.view.center の CGPoint を代入しました。
2秒で画面の左上から、真ん中に View を移動するサンプルコードを書いてみます。
@implementation ViewController
– (void)viewDidLoad
{
[superviewDidLoad];
UIView *v = [[UIViewalloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
v.backgroundColor = [UIColorgreenColor];
[self.view addSubview:v];
[UIViewanimateWithDuration:2animations:^{
v.center = self.view.center;
}];
}
@end