設置動畫,旋轉

   CGRect frame = self.imageView.frame;
    // 創建臨時的圖片,保留原圖。一定要<span style="font-family: Menlo; font-size: 18px; color: rgb(187, 44, 162);">self</span><span style="font-family: Menlo; font-size: 18px;">.</span><span style="font-family: Menlo; font-size: 18px; color: rgb(79, 129, 135);">imageView</span><span style="font-family: Menlo; font-size: 18px;">.</span><span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 18px;">userInteractionEnabled</span><span style="font-family: Menlo; font-size: 18px;"> = </span><span style="font-family: Menlo; font-size: 18px; color: rgb(187, 44, 162);">YES</span><span style="font-family: Menlo; font-size: 18px;">;</span><div><span style="color: #000000">
</span></div>
    UIImageView* tempImageView = [[UIImageView alloc]initWithFrame:frame];
    tempImageView.image = [UIImage imageNamed:@"1.jpg"];
    [self.view addSubview:tempImageView];
    // 縮小
    CGAffineTransform transform = CGAffineTransformMakeScale(0.1, 0.1);
    // 順時針旋轉,這裏有位置變化,還沒有想到在這個過程中旋轉2周,現在是右轉約半周
    transform = CGAffineTransformRotate(transform, M_PI*1.99/2);
    // 設置目的地爲右下角
    CGPoint center = CGPointMake(self.view.bounds.size.width, self.view.bounds.size.height);
    [UIView animateWithDuration:2 delay:0 usingSpringWithDamping:1 initialSpringVelocity:3 options:0 animations:^{
        tempImageView.transform = transform;
        tempImageView.center = center;
    } completion:^(BOOL finished){
        [tempImageView removeFromSuperview];
    }];

發佈了51 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章