网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

UIKit框架(3)UIView的动画处理方式

可以将UIView对象的位置及尺寸变化处理成动画效果

创新互联建站自2013年起,先为新都等服务建站,新都等地企业,进行企业商务咨询服务。为新都企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

  • 基本的动画处理方式

//标识动画的开始位置
+ (void)beginAnimations:(NSString *)animationID context:(void *)context
//标识动画的结束位置,并开始动画
+ (void)commitAnimations
//设置动画执行时间,单位为秒 
+ (void)setAnimationDuration:(NSTimeInterval)duration  
//动画重复次数,默认为1
+ (void)setAnimationRepeatCount:(float)repeatCount

如:通过改变btn的大小使用动画处理

CGRect frame = self.btn.frame;
frame.size.width *= 1.2;
frame.size.height *= 1.2;
[UIView beginAnimations:@"btn" context:nil];
[UIView setAnimationDuration:0.5];
self.btn.frame = frame;
[UIView commitAnimations];

  • block方式的动画处理

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delayoptions:(UIViewAnimationOptions)options animations:(void (^)(void))animationscompletion:(void (^)(BOOL finished))completion

如:

CGRect frame = self.btn.frame;
frame.size.width *= 1.2;
frame.size.height *= 1.2;
[UIView animateWithDuration:0.5 animations:^{
    self.btn.frame = frame;
}];

  • 动画处理中使用形变属性

动画处理中使用形变属性是一个非常好的做法

基于自身初始形变值进行形变:

//位置形变
CGAffineTransform CGAffineTransformMakeTranslation ( CGFloat tx, CGFloat ty );
//尺寸形变
CGAffineTransform CGAffineTransformMakeScale ( CGFloat sx, CGFloat sy ); 
//旋转形变
CGAffineTransform CGAffineTransformMakeRotation ( CGFloat angle );

基于指定形变值进行形变:

//位置形变
CGAffineTransform CGAffineTransformTranslate ( CGAffineTransform t, CGFloat tx,CGFloat ty ); 
//尺寸形变
CGAffineTransform CGAffineTransformScale ( CGAffineTransform t, CGFloat sx,CGFloat sy );  
//旋转形变
CGAffineTransform CGAffineTransformRotate ( CGAffineTransform t, CGFloat angle );

如:

CGAffineTransform transform = CGAffineTransformScale(self.btn.transform, 1.2, 1.2);
[UIView beginAnimations:@"btn" context:nil];
[UIView setAnimationDuration:0.5];
self.btn.transform = transform;
[UIView commitAnimations];

形变原始值常量:

const CGAffineTransform CGAffineTransformIdentity;


分享名称:UIKit框架(3)UIView的动画处理方式
转载注明:http://bjjierui.cn/article/pddijd.html

其他资讯