常用控制器

2017-12-03  本文已影响9人  FunkyRay

关于UIViewController

1.两个UIViewController之间跳转时的生命周期:

2.UIViewController创建时的生命周期:

关于UINavigationController

1.统一设置导航栏按钮:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {

    // 在该方法里做你想要做的事情
    [super pushViewController:viewController animated:animated];    
}

2.推出控制器并隐藏tabBar:

 viewController.hidesBottomBarWhenPushed = YES;

3.左滑返回无效的方法:

分析:
1.手势被清空   
2.可能手势代理做了一些事情,导致手势失效)
设置该属性interactivePopGestureRecognizer的delegate

4.设置导航条背景图片的方法:

[navBar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];

5.不要给UIScrollView子控件增加内边距的方法:

 self.automaticallyAdjustsScrollViewInsets = NO;

// iOS 11后更改的新方法:
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

关于UITabBarController

1.TabBar中的图片被渲染的解决办法

UIImageRenderingModeAutomatic  // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式。  
UIImageRenderingModeAlwaysOriginal  // 始终绘制图片原始状态,不使用Tint Color。
UIImageRenderingModeAlwaysTemplate  // 始终根据Tint Color绘制图片,忽略图片的颜色信息。

UIImage.renderingMode = UIImageRenderingModeAlwaysOriginal;

2.设置按钮颜色属性:

UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor blackColor];
[item setTitleTextAttributes:attrs forState:UIControlStateSelected];

注意:设置字体尺寸只有设置正常状态下才会有效果

3.设置全局TabBar方法注意点:

4.调用系统私有类和属性的方法:

上一篇 下一篇

猜你喜欢

热点阅读