iOS 属性动画

来源:互联网 发布:阿里云服务器规格 编辑:程序博客网 时间:2024/06/05 02:14
//第一步:准备动画
    //参数1:动画的作用,区分多个动画的标识; 参数2:传递参数;NULL:C语言中使用 nil:OC使用
    [UIView beginAnimations:@"改变大小" context:NULL];
    //在准备动画的时候可以设置动画属性;
    [UIView setAnimationDuration:0.5];//持续时间
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(didFinish)];
    [UIView setAnimationDelay:0];//设置动画延时时间
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画曲线(淡进淡出)
    [UIView setAnimationRepeatCount:10];//动画重复次数
    [UIView setAnimationRepeatAutoreverses:YES];//动画往返执行(必须设置动画重复次数)
    
    
    //第二步:修改view的属性(不是所有的属性都可以修改的frame,center视图位置,bounds视图大小,backgroundColor,alpha,transform视图转换)(可以修改多个属性)
    self.changeView.frame = CGRectMake(10, 10, 150, 150);
    self.changeView.backgroundColor = [UIColor greenColor];
    self.changeView.center = CGPointMake(120, 300);
    
    //第三步:提交并执行动画
    [UIView commitAnimations];
0 0
原创粉丝点击