码迷,mamicode.com
首页 > 移动开发 > 详细

如何解决IOS 动画中 Autolayout 与View Transforms的冲突

时间:2014-04-27 21:10:53      阅读:1047      评论:0      收藏:0      [点我收藏+]

标签:blog   class   com   code   img   http   div   java   javascript   style   ext   

IOS 的动画放大与缩小,并非按照找它的中心点放大和缩小,而是左上角 。我分析了下原来是Autolayout 与View Transforms的冲突造成的。

 

mamicode.com,码迷
- (void) addSubviewWithZoomInAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option
{
// first reduce the view to 1/100th of its original dimension
CGAffineTransform trans = CGAffineTransformScale(view.transform, 0.01, 0.01);
view.transform = trans;    // do it instantly, no animation
[self addSubview:view];
// now return the view to normal dimension, animating this tranformation
[UIView animateWithDuration:secs delay:0.0 options:option
animations:^{
view.transform = CGAffineTransformScale(view.transform, 100.0, 100.0);
}
completion:nil];    
}

- (void) removeWithZoomOutAnimation:(float)secs option:(UIViewAnimationOptions)option
{
[UIView animateWithDuration:secs delay:0.0 options:option
animations:^{
self.transform = CGAffineTransformScale(self.transform, 0.01, 0.01);
}
completion:^(BOOL finished) { 
[self removeFromSuperview]; 
}];
}
mamicode.com,码迷

 



 

解决方案: 

Disable auto layout:

self.imageView.translatesAutoresizingMaskIntoConstraints = YES;

 

【1】

http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used/14105757#14105757

如何解决IOS 动画中 Autolayout 与View Transforms的冲突,码迷,mamicode.com

如何解决IOS 动画中 Autolayout 与View Transforms的冲突

标签:blog   class   com   code   img   http   div   java   javascript   style   ext   

原文地址:http://www.cnblogs.com/rubick/p/3694719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!