UIView缩放为0使用CGAffineTransformMakeScale [英] UIView scale to 0 using CGAffineTransformMakeScale

查看:116
本文介绍了UIView缩放为0使用CGAffineTransformMakeScale的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用CGAffineTransformMakeScale将UIView缩放到0(宽度和高度为0)?



view.transform = CGAffineTransformMakeScale(0.0f,0.0f);



为什么会抛出<错误> ;: CGAffineTransformInvert:奇异矩阵。





<还有另一种将UIView缩小到0的方法。




  [UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.3];
view.frame = CGRectMake(view.center.x,view.center.y,0,0);

[UIView commitAnimations];


解决方案

有很多时候,反转您的变换矩阵。矩阵的逆是一些矩阵M',使得矩阵M和逆矩阵M'的乘积是标识矩阵I. b
$ b <1> = M * M '



零矩阵没有逆矩阵,因此出现错误消息。


Is it possible to scale a UIView down to 0 (width and height is 0) using CGAffineTransformMakeScale?

view.transform = CGAffineTransformMakeScale(0.0f, 0.0f);

Why would this throw an error of "<Error>: CGAffineTransformInvert: singular matrix." ?



Update: There is another way of scaling down a UIView to 0

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.3]; 
view.frame = CGRectMake(view.center.x, view.center.y, 0, 0);

[UIView commitAnimations];

解决方案

There are lots of times when the underlying frameworks need to invert your transform matrix. The inverse of a matrix is some matrix M' such that the product of your matrix M and the inverse matrix M' is the identify matrix 1.

1 = M * M'

The zero matrix does not have an inverse, hence the error message.

这篇关于UIView缩放为0使用CGAffineTransformMakeScale的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆