// MBProgressHUD.m(版本 0.9.1)里面MBBarProgressView类的drawRect:方法里:
if (isnan(angle)) angle = 0;
isnan()函数用来判断一个变量(比如上面的angle)是不是数字,如果不是数字,返回YES
(isnan = is not a number)
[TOC]忽略编译器警告
忽略编译器警告(使用了已废弃方法、创建未使用的变量等),例子:
-Wdeprecated
表示已废弃
// SVProgressHUD.m里的361行
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
//此处是你写的iOS7以后已废弃的方法
stringSize = [string sizeWithFont:self.stringLabel.font constrainedToSize:CGSizeMake(200.0f, 300.0f)];
#pragma clang diagnostic pop
说MJRefresh是垃圾的这位大神自己写了个挺简洁的下拉刷新控件PRRefreshControl
//正常状态下,下拉后箭头朝下
case PRRefreshControlStateNormal:
{
[UIView animateWithDuration:.2f animations:^{
self.arrowImageView.hidden = NO;
self.arrowImageView.transform = CGAffineTransformIdentity;
}];
[self.activityIndicator stopAnimating];
break;
}
这里要说的是self.arrowImageView.transform = CGAffineTransformIdentity
这句话,关于CGAffineTransformIdentity,苹果文档注释如下:
struct CGAffineTransform {
CGFloat a, b, c, d;
CGFloat tx, ty;
};
/* The identity transform: [ 1 0 0 1 0 0 ]. */
const CGAffineTransform CGAffineTransformIdentity
/* Return the transform [ a b c d tx ty ]. */
CGAffineTransform CGAffineTransformMake(CGFloat a, CGFloat b,
CGFloat c, CGFloat d, CGFloat tx, CGFloat ty)
/* Return a transform which translates by `(tx, ty)':
t' = [ 1 0 0 1 tx ty ] */
CGAffineTransform CGAffineTransformMakeTranslation(CGFloat tx,
CGFloat ty)
[ 1 0 0 1 0 0 ]
是个什么鬼呢?
再次复制这一段
struct CGAffineTransform {
CGFloat a, b, c, d;
CGFloat tx, ty;
};
在二维空间里,如果原始坐标是(X,Y, 1)的话
|a b 0 |
|X,Y, 1| |c d 0 | = [aX + cY + tx, bX + dY + ty, 1] ;
|tx ty 1|
乘以矩阵之后(X,Y, 1)→(aX + cY + tx, bX + dY + ty, 1)
那么[ 1 0 0 1 0 0 ](CGAffineTransformIdentity)就相当于做了如下变换
|1 0 0 |
|X,Y, 1| |0 1 0 | = [X, Y, 1] ;
|0 0 1|
所以self.arrowImageView.transform = CGAffineTransformIdentity;
这句话的意思就相当于重置位置的作用
也有人说
每次变换前都要置位,不然你变换用的坐标系统不是屏幕坐标系统(即绝对坐标系统),而是上一次变换后的坐标系统
CGAffineTransformMake
和CGAffineTransformMakeTranslation
同理