一.UITabelView
1.去掉多余的cell
_tableView.tableFooterView = [[UIView alloc] init];
2.tableview或者scrollview不能再VC中滑到顶
self.automaticallyAdjustsScrollViewInsets = NO;
3.tableview加个默认隐藏的搜索框
self.tableView.tableHeaderView=self.searchDisplayController.searchBar;
self.tableView.contentOffset=CGPointMake(0,CGRectGetHeight(self.searchDisplayController.searchBar.bounds));
4.全屏显示tableview的分割线
cell.layoutMargins=UIEdgeInsetsZero;
_mineTableView.separatorInset=UIEdgeInsetsZero;
_mineTableView.layoutMargins=UIEdgeInsetsZero;
5.修改cell被选中的颜色
cell.selectedBackgroundView.backgroundColor= [UIColorredColor];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
二.导航栏、VC
1.滑动隐藏导航栏
self.automaticallyAdjustsScrollViewInsets = NO;
2.导航栏返回键带的title不好看,换掉
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
3.把navigationBar变成透明
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.translucent = YES;
4.去掉navigationBar下面的黑色细线
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
5.去掉tabBar下面的黑色细线
[self.tabBarController.tabBar setBackgroundImage:[UIImage new]];
[self.tabBarController.tabBar setShadowImage:[UIImage new]];
6.导航栏遮住了Y为0 的控件
(1)
self.edgesForExtendedLayout = UIRectEdgeNone;
(2)
self.navigationController.navigationBar.translucent = NO;
3.UIbutton
1.文字左侧显示
button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
button.contentEdgeInsets=UIEdgeInsetsZero;
4.收起键盘(最好在基类)
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
}
5.截屏
- (void)screenShot
{
UIViewController *vc = [WPMethodManager getFrontViewController];
CGSize size = vc.view.frame.size;
// 开启上下文,使用参数之后,截出来的是原图(YES 0.0 质量高)
UIGraphicsBeginImageContextWithOptions(size, YES, 0);
// 裁剪的关键代码,要裁剪的矩形范围
CGRect rect = CGRectMake(0, -20, size.width, size.height + 20);
//注:iOS7以后renderInContext:由drawViewHierarchyInRect:afterScreenUpdates:替代
[vc.view drawViewHierarchyInRect:rect afterScreenUpdates:YES];
// 从上下文中,取出UIImage
UIImage *shotImage = UIGraphicsGetImageFromCurrentImageContext();
//保存
UIImageWriteToSavedPhotosAlbum(shotImage, nil, nil, nil);
//结束上下文(移除栈顶上下文)
UIGraphicsEndImageContext();
}
三.Tabbar
1.pop返回指定的tabbar selectedIndex
AYTabBarController *tabBar = (AYTabBarController *)kkeyWindow.rootViewController;
[self.navigationController popToRootViewControllerAnimated:YES];
tabBar.tabBar.hidden = NO;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
tabBar.selectedIndex = 1;
});
注意:tabbarC如果是自定义的就拿到自定义的tabbarC
四.UITextField、UITextView
1.文字内容偏移
1.UITextField
_circleNameTextField.leftView = [[UIView alloc] initWithFrame:kCGRect(0, 0, 10, _circleNameTextField.jk_height)];
_circleNameTextField.leftViewMode = UITextFieldViewModeAlways;
2.UITextView
_detailTextView.textContainerInset = UIEdgeInsetsMake(10, 10, 0, 0);