(1)添加手势收起键盘
UITapGestureRecognizer*tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewTap:)];
//可以通过设置这个布尔值,来设置手势被识别时触摸事件是否被传送到视图当值为YES的时候,系统会识别手势,并取消触摸事件;为NO的时候,手势识别之后,系统将触发触摸事件。
tap.cancelsTouchesInView=NO;
[backview addGestureRecognizer:tap];
-(void)viewTap:(UITapGestureRecognizer *)tap
{
[self.view endEditing:YES];
}
(2)常用算法函数
rand() ----随机数,常用
abs() / labs() ----整数绝对值
fabs() / fabsf() / fabsl() ----浮点数绝对值
floor() / floorf() / floorl() ----向下取整,常用
ceil() / ceilf() / ceill() ----向上取整,常用
round() / roundf() / roundl() ----四舍五入
sqrt() / sqrtf() / sqrtl() ----求平方根
fmax() / fmaxf() / fmaxl() ----求最大值
fmin() / fminf() / fminl() ----求最小值
hypot() / hypotf() / hypotl() ----求直角三角形斜边的长度
fmod() / fmodf() / fmodl() ----求两数整除后的余数
modf() / modff() / modfl() ----浮点数分解为整数和小数
frexp() / frexpf() / frexpl() ----浮点数分解尾数和二为底的指数
sin() / sinf() / sinl() ----求正弦值
sinh() / sinhf() / sinhl() ----求双曲正弦值
cos() / cosf() / cosl() ----求余弦值
cosh() / coshf() / coshl() ----求双曲余弦值
tan() / tanf() / tanl() ----求正切值
tanh() / tanhf() / tanhl() ----求双曲正切值
asin() / asinf() / asinl() ----求反正弦值
asinh() / asinhf() / asinhl() ----求反双曲正弦值
acos() / acosf() / acosl() ----求反余弦值
acosh() / acoshf() / acoshl() ----求反双曲余弦值
atan() / atanf() / atanl() ----求反正切值
atan2() / atan2f() / atan2l() ----求坐标值的反正切值
atanh() / atanhf() / atanhl() ----求反双曲正切值
(3)MJ刷新
//下拉
@weakify(self);
_collectionView.mj_header = [MJRefreshNormalHeaderheaderWithRefreshingBlock:^{
//加载上一页,进行页码的变化和数据的请求
@strongify(self);
[self.collectionView.mj_footerresetNoMoreData];//重置一下
}];
//上推
_collectionView.mj_footer = [MJRefreshAutoNormalFooterfooterWithRefreshingBlock:^{
//加载下一页,进行页码的变化和数据的请求
@strongify(self);
}];
(4)状态栏颜色
//设置状态栏颜色
- (void)setStatusBarBackgroundColor:(UIColor *)color {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = color;
}
}