记录下平时写代码中遇到的各种需求的解决方案,方便以后查看。算是把GitHub当成云笔记了。
- navigationBar的隐藏 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10- - (void)viewWillAppear:(BOOL)animated { 
 [super viewWillAppear:animated];
 [self.navigationController setNavigationBarHidden:YES animated:animated];
 }
 - (void)viewWillDisappear:(BOOL)animated {
 [super viewWillDisappear:animated];
 [self.navigationController setNavigationBarHidden:NO animated:animated];
 }
- 设置cell分割线 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12- - (void)drawRect:(CGRect)rect { 
 [super drawRect:rect];
 CGContextRef context = UIGraphicsGetCurrentContext();
 CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
 CGContextFillRect(context, rect);
 //上分割线
 CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor);
 CGContextStrokeRect(context, CGRectMake(0, -4, rect.size.width, 4));
 //下分割线
 CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor);
 CGContextStrokeRect(context, CGRectMake(0, -4, rect.size.width, 4));
 }
- tableView添加pan手势 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15- - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer 
 {
 UIView *gestureView = [gestureRecognizer view];
 CGPoint translation = [gestureRecognizer translationInView:[gestureView superview]];
 // Check for horizontal gesture
 if (fabsf(translation.x) > fabsf(translation.y))
 {
 return YES;
 }
 return NO;
 }
- tableView手势冲突 - 1 
 2
 3
 4
 5
 6- - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 
 if ([touch.view isDescendantOfView:autocompleteTableView]) {
 return NO;
 }
 return YES;
 }
- 去掉tableView底部空白 - 1 - [tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]]; 
- tableViewCell分割线顶头显示 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15- static void setLastCellSeperatorToLeft(UITableViewCell* cell) 
 {
 if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
 [cell setSeparatorInset:UIEdgeInsetsZero];
 }
 if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
 [cell setLayoutMargins:UIEdgeInsetsZero];
 }
 if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
 [cell setPreservesSuperviewLayoutMargins:NO];
 }
 }
- cocoapods不更新本地库install - 1 
 2- pod install --verbose --no-repo-update 
 pod update --verbose --no-repo-update
- button setBackGroundImage和setImage的区别 - setBackGroundImage会把图片拉伸
- setImage依然按照源比例显示图片