IOS之UI添加動畫

UIView提供了類方法beginAnimations開始一個動畫,這種寫法很像Java中jdbc中提交一個事務一樣。

    [UIView beginAnimations:nil context:nil]; //設置動畫開始

    [UIView setAnimationDuration:.8];//設置動畫時間


//動畫操作

    UIView *redBtn=[self.view viewWithTag:kRedBtnTag];

    CGAffineTransform transForm=redBtn.transform;

    redBtn.transform=CGAffineTransformRotate(transForm, sender.tag==7?-M_PI_4:M_PI_4);


    //提交動畫結束

    [UIView commitAnimations];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章