iOS的小技巧

UITableView相关

1、TableView不显示没内容的Cell怎么办?

self.tableView.tableFooterView = [[UIView alloc] init];

2、怎么在不新建一个Cell的情况下调整separaLine的位置?

_myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);

3、怎么把tableview里cell的小对勾的颜色改成别的颜色?

_mTableView.tintColor = [UIColor redColor];

UINavigationController相关

1、怎么像safari一样滑动的时候隐藏navigationbar?

navigationController.hidesBarsOnSwipe = Yes

2、导航条返回键带的title太讨厌了,怎么让它消失!

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                     forBarMetrics:UIBarMetricsDefault];

3、自定义了leftBarbuttonItem左滑返回手势失效了怎么办?

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                         initWithImage:img
                                         style:UIBarButtonItemStylePlain
                                         target:self
                                         action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

4、怎么把我的navigationbar弄成透明的而不是带模糊的效果?

[self.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;

UICollectionView相关

CollectionView 怎么实现tableview那种悬停的header?

CSStickyHeaderFlowLayou

UIImage相关

拉伸图片的时候怎么才能让图片不变形?

UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];

UIStatusBar相关

本来我的statusbar是lightcontent的,结果用UIImagePickerController会导致我的statusbar的样式变成黑色,怎么办?

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

UITextfield相关

怎么改变uitextfield placeholder的颜色和位置?
继承uitextfield,重写这个方法

- (void) drawPlaceholderInRect:(CGRect)rect {
    [[UIColor blueColor] setFill];
    [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];

你可能感兴趣的:(iOS的小技巧)