一.UITabelView
1.去掉多余的cell
_tableView.tableFooterView = [[UIView alloc] init];
2.tableview或者scrollview不能再VC中滑到頂
self.automaticallyAdjustsScrollViewInsets = NO;
3.tableview加個(gè)默認(rèn)隱藏的搜索框
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;
二.導(dǎo)航欄予颤、VC
1.滑動(dòng)隱藏導(dǎo)航欄
self.automaticallyAdjustsScrollViewInsets = NO;
2.導(dǎo)航欄返回鍵帶的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下面的黑色細(xì)線
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
5.去掉tabBar下面的黑色細(xì)線
[self.tabBarController.tabBar setBackgroundImage:[UIImage new]];
[self.tabBarController.tabBar setShadowImage:[UIImage new]];
6.導(dǎo)航欄遮住了Y為0 的控件
(1)
self.edgesForExtendedLayout = UIRectEdgeNone;
(2)
self.navigationController.navigationBar.translucent = NO;
3.UIbutton
1.文字左側(cè)顯示
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;
// 開啟上下文,使用參數(shù)之后,截出來(lái)的是原圖(YES? 0.0 質(zhì)量高)
UIGraphicsBeginImageContextWithOptions(size, YES, 0);
// 裁剪的關(guān)鍵代碼,要裁剪的矩形范圍
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);
//結(jié)束上下文(移除棧頂上下文)
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.文字內(nèi)容偏移
????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);