- 清空所以子視圖
[view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
- 使tableView的grouped類型的組頭出現(xiàn)了一段默認(rèn)的高度,取消方法
//1.設(shè)置tableHeaderView的Frame
CGRect frame = CGRectMake(0, 0, 0, 0.1);
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:frame];
//2.把tableView整體進(jìn)行偏移
self.tableView.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
//3.針對沒有頭部視圖的,只需要實(shí)現(xiàn)這個代理方法
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
3.iOS截取UIView,保存為Image
#pragma mark 生成image
- (UIImage *)makeImageWithView:(UIView *)view
{
CGSize size = bgView.bounds.size;
/*
下面方法,
第一個參數(shù)表示區(qū)域大小。
第二個參數(shù)表示是否是非透明的。如果需要顯示半透明效果,需要傳NO,否則傳YES。
第三個參數(shù)就是屏幕密度了,關(guān)鍵就是第三個參數(shù)。
*/
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- 改變pushViewCollectionView的跳轉(zhuǎn)樣式
/*
方法一:
注意:使用view的layer屬性,要在頭文件里導(dǎo)入
#import <QuartzCore/QuartzCore.h>
和添加QuartzCore.framework
*/
transition.type = kCATransitionFade;//類型(具體類型看源碼)
transition.subtype = kCATransitionFromRight;//從右邊push(具體看源碼)
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
/*
方法二:
*/
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:gradeVc];
nc.modalTransitionStyle = UIModalPresentationNone;
[self.window.rootViewController presentViewController:nc animated:YES completion:nil];
- 隨機(jī)顏色的宏定義
#define random(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
#define randomColor random(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))