1、動畫切換window的根控制器
// options是動畫選項(xiàng)
[UIView transitionWithView:[UIApplication sharedApplication].keyWindow duration:0.5f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
BOOL oldState = [UIView areAnimationsEnabled]; ? ? ??
[UIView setAnimationsEnabled:NO];? ? ? ??
[UIApplication sharedApplication].keyWindow.rootViewController = [RootViewController new]; ? ? ?
[UIView setAnimationsEnabled:oldState];?
? } completion:^(BOOLfinished) { ??
}];
2、開發(fā)中如果要動態(tài)修改tableView的tableHeaderView或者tableFooterView的高度,需要給tableView重新設(shè)置,而不是直接更改高度。正確的做法是重新設(shè)置一下tableView.tableFooterView = 更改過高度的view。為什么?其實(shí)在iOS8以上直接改高度是沒有問題的,在iOS8中出現(xiàn)了contentSize不準(zhǔn)確的問題,這是解決辦法。
3、collectionView的內(nèi)容小于其寬高的時候是不能滾動的,設(shè)置可以滾動:
collectionView.alwaysBounceHorizontal = YES;
collectionView.alwaysBounceVertical = YES;
4、顏色轉(zhuǎn)圖片
+ (UIImage*)cl_imageWithColor:(UIColor*)color {
CGRectrect =CGRectMake(0.0f,0.0f,1.0f,1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRefcontext =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [colorCGColor]);
CGContextFillRect(context, rect);
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();returnimage;
}