改变UITabBarController的高度方法

很多人可能遇到过通过代码创建了一个UITabBarController,并设置了tabbar的高度为40,结果发现上方的view和下面的tabbar中间出现了一个间隙。调整view的frame也没有用,怎么能刷新一下页面把这个间隙去掉呢?

只改tabbar的frame是不够的,不要忘了同时要改这个UITransitionView的高度。即改变TabBar加载的viewControllers的显示View高度,如图:

代码如下:

[cpp] view plain copy
 
 print?
  1. // 改变tabBarController高度  
  2. UITabBarController *mTabBar = [[UITabBarController alloc] init];  
  3. mTabBar.tabBar.frame = CGRectMake(0, 460-40, 320, 40);  
  4. UIView * transitionView = [[mTabBar.view subviews] objectAtIndex:0];  
  5. transitionView.height = 460-40;  

7.改变导航栏的属性

[UINavigationBar appearance].barTintColor = [UIColor grayColor];

    [UINavigationBar appearance].tintColor = [UIColor whiteColor];

    [UINavigationBar appearance].barStyle = UIBarStyleBlack;

    

    8.改变tabBarController 中的tabBar的大小

    for (UIBarItem *item in mainTab.tabBar.items) {

        [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

[UIFont fontWithName:@"Helvetica" size:20.0], NSFontAttributeName, nil]

                            forState:UIControlStateNormal];

        

    }

其他小技巧

1.隐藏多余的tableView的cell分割线

self.tableView.tableFooterView= [[UIViewalloc]init];

2.取消系统自带的返回字样

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

3.滑动时隐藏navigation

self.navigationController.hidesBarsOnSwipe=YES;

4.页面跳转是隐藏tabBar

TwoViewController *twoVC = [[TwoViewController alloc] init];

twoVC.hidesBottomBarWhenPushed =YES;

5.ScrollView不能滑到顶

self.automaticallyAdjustsScrollViewInsets=NO;

6.按钮点击发光效果

button.showsTouchWhenHighlighted =YES;

7.长按手势只执行一次

if(sender.state == UIGestureRecognizerState)

8.隐藏状态栏

- (BOOL)prefersStatusBarHidden

{

returnYES;

}

9.在使用view的缩放的时候,layer.border.width随着view的放大,会出现锯齿化的问题。

self.layer.allowsEdgeAntialiasing = YES;

 

10.设置不同页面的title

- (void)viewDidAppear:(BOOL)animated {

    self.navigationItem.title = @"电影";

}

11.

当数据不多,collectionView.contentSize小于collectionView.frame.size的时候,UICollectionView是不会滚动的

 self.Cov.alwaysBounceVertical = YES;

 

 

原文地址:https://www.cnblogs.com/mingjieLove00/p/5483949.html