标签:
把子控制器添加到导航控制器中
(1)
YYOneViewController *one=[[YYOneViewController alloc]init];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:one];
(2)
UINavigationController *nav=[[UINavigationControlleralloc]init];
self.window.rootViewController=nav;
YYOneViewController *one = [[YYOneViewController alloc] init];
[nav addChildViewController:one];
(3)
YYOneViewController *one = [[YYOneViewController alloc] init];
nav.viewControllers=@[one];(添加到导航控制器的栈中)
当前子控制器界面导航栏的标题以及对应返回标题的设置
self.navigationItem.title=@"第一个界面";
self.navigationItem.backBarButtonItem=[[UIBarButtonItemalloc]initWithTitle:@"返回一"style:UIBarButtonItemStylePlain target:nilaction:nil];
给导航栏添加按钮
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:nil action:nil];
界面跳转
跳转到第二个界面(当前为第三个,移除当前栈顶的控制器) [self.navigationControllerpopViewControllerAnimated:YES];
移除处理栈底控制器之外的所有控制器 [self.navigationControllerpopToRootViewControllerAnimated:YES];
只要传入栈中的某一个控制器,就会跳转到指定控制器 [self.navigationController popToViewController:viewcontroller animated:animated];
iOS7之后 要想改变navigationbar的颜色 可以这样子改
self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#3A3A3A" alpha:1.0f];
默认带有一定透明效果,可以使用以下方法去除系统效果
[self.navigationController.navigationBar setTranslucent:NO];
给navigationBar设置图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"32050"] forBarMetrics:UIBarMetricsDefault];
改变UINavigationBar导航条标题颜色和字体
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:0 green:0.7 blue:0.8 alpha:1], NSForegroundColorAttributeName,
[UIColor colorWithRed:0 green:0.7 blue:0.8 alpha:1],NSShadowAttributeName,
[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], NSShadowAttributeName,
[UIFont fontWithName:@"Arial-Bold" size:0.0], NSFontAttributeName,
nil]
];
改变状态栏的颜色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[viewController setNeedsStatusBarAppearanceUpdate];如果没效果,
可在plist文件里设置View controller-based status bar appearance = NO
设置为:View Controller 不对status Bar 显示进行操作
// 实现navigationController的代理
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
viewController.navigationController.navigationBar.barTintColor = MainAppColor;
[viewController.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,[UIFont fontWithName:@"Helvetica Neue" size:19.0f], NSFontAttributeName,nil]];
viewController.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
}
在调用系统相册、相机发现是英文的系统相簿界面后标题显示“photos”,但是手机语言已经设置显示中文,在info.plist设置解决问题 info.plist里面添加Localized resources can be mixed YES 表示是否允许应用程序获取框架库内语言。
获取view上所有的层级结构
- (NSString *)digView:(UIView *)view { if ([view isKindOfClass:[UITableViewCell class]]) return @""; // 1.初始化 NSMutableString *xml = [NSMutableString string]; // 2.标签开头 [xml appendFormat:@"<%@ frame=\"%@\"", view.class, NSStringFromCGRect(view.frame)]; if (!CGPointEqualToPoint(view.bounds.origin, CGPointZero)) { [xml appendFormat:@" bounds=\"%@\"", NSStringFromCGRect(view.bounds)]; } if ([view isKindOfClass:[UIScrollView class]]) { UIScrollView *scroll = (UIScrollView *)view; if (!UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsetsZero, scroll.contentInset)) { [xml appendFormat:@" contentInset=\"%@\"", NSStringFromUIEdgeInsets(scroll.contentInset)]; } } // 3.判断是否要结束 if (view.subviews.count == 0) { [xml appendString:@" />"]; return xml; } else { [xml appendString:@">"]; } // 4.遍历所有的子控件 for (UIView *child in view.subviews) { NSString *childXml = [self digView:child]; [xml appendString:childXml]; } // 5.标签结尾 [xml appendFormat:@"</%@>", view.class]; return [xml copy]; }
标签:
原文地址:http://www.cnblogs.com/diyigechengxu/p/5786310.html