关闭

03-IOS坐标系统 动画效果

411人阅读 评论(0) 收藏 举报
分类:

判断是否在执行动画
if(self.image.isanimation) return;

1> frame:能修改位置和尺寸
2> center:能修改位置
3> bounds:能修改尺寸(x\y一般都是0)以自己左上角为原点
4> transform:能修改大小 尺寸 旋转角度

2.transform操作图片

//    放大缩小
- (
IBAction)bigAndSmall:(UIButton*)sender {
 
if(sender.tag== 10)
  {
   
CGAffineTransformtrans = self.MyView.transform;
   
CGAffineTransformform = CGAffineTransformScale(trans, 1.2, 1.2);
   
self.MyView.transform= form;
  }
else if (sender.tag== 20)
  {
     
CGAffineTransformtrans = self.MyView.transform;
     
CGAffineTransformform = CGAffineTransformScale(trans, 0.9, 0.9);
     
self.MyView.transform= form;
  }
}
//    旋转
- (
IBAction)rotate:(UIButton*)sender {
   
CGAffineTransformtrans = self.MyView.transform;
   
CGAffineTransformform = CGAffineTransformRotate(trans, M_PI_4);
   
self.MyView.transform= form;

}
//    平移
- (
IBAction)translation:(UIButton*)sender {
   
CGAffineTransformtrans = self.MyView.transform;
   
CGAffineTransformform = CGAffineTransformTranslate(trans, 0, 10);
   
self.MyView.transform= form;

}
//    复位
- (
IBAction)recove:(UIButton*)sender {
   
self.MyView.transform= CGAffineTransformIdentity;
}



 


[UIView beginAnimations:nil context:nil];//开始动画
[UIView setAnimationDuration:2.0];  //设置时间 s
[UIViewsetAnimationRepeatCount:100];//执行次数
要执行动画的代码
[UIView commitAnimations];              //提交动画


4.block实现动画

  UIView animateWithDuration:<#(NSTimeInterval)#> animations:^{
        <#code#>
    }



5.延迟调用
//延迟调用
  [selfperformSelector:@selector(dismissViewControllerAnimated:completion:)withObject:nilafterDelay:1.0f];




6.转场动画


- (void)rightBtnAction
{
  //设置动画的翻转方向
    UIViewAnimationTransition transition =_listBtn.hidden? UIViewAnimationTransitionFlipFromLeft:UIViewAnimationTransitionFlipFromRight;

    [UIViewanimateWithDuration:.35animations:^{
        [UIViewsetAnimationTransition:transitionforView:_imagecache:YES];
    }];
   
   
_rightBtn.hidden= !_rightBtn.hidden;
   
_rightBtn1.hidden= !_rightBtn1.hidden;
  
}




7.实现动画左翻转  然后右翻转回来


- (void)buttonAction {
   
    
UIView *customView =self.navigationItem.rightBarButtonItem.customView;
   
   
//切换按钮的显示
   
UIButton *postButton = (UIButton*)[customView viewWithTag:100];
   
UIButton *listButton = (UIButton*)[customView viewWithTag:101];
    postButton.
hidden= !postButton.hidden;
    listButton.
hidden= !listButton.hidden;
   
   
//设置动画的翻转方向
   
UIViewAnimationTransition transition = postButton.hidden? UIViewAnimationTransitionFlipFromLeft:UIViewAnimationTransitionFlipFromRight;
   
   
//翻转动画
    [
UIViewbeginAnimations:nilcontext:nil];
    [
UIViewsetAnimationDuration:.35];
   
    [
UIViewsetAnimationTransition:transitionforView:customViewcache:YES];
   
    [
UIViewcommitAnimations];
   
}




0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:116215次
    • 积分:3656
    • 等级:
    • 排名:第9228名
    • 原创:218篇
    • 转载:65篇
    • 译文:0篇
    • 评论:5条
    最新评论