2012年1月6日 星期五

用setAnimation呈現動畫


- (void)showLines{
    lines.hidden = NO; //設定原本是隱藏
    CGPoint Lpos = lines.center;
    Lpos.y = -12.0f; //原本的位置是y座標在-12
    lines.center = Lpos;
    //這裡以上是動以前的位置
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    //這裡以下是預計要動的目的地
    Lpos.y = 10.0f; //讓要移動的物件從-12移到y座標10, 也就是垂直往下移動
    lines.center = Lpos;
    [UIView commitAnimations]; //執行移動的指令
}

0 意見:

張貼留言