iOS 导航栏的一些使用属性记录(备忘)
来源:互联网 发布:淘宝口红代购ysl 编辑:程序博客网 时间:2024/05/01 20:58
1, 代码块---copy
2, 代理---weak(strong不能被dealloc释放) dealloc 里面释放 delegate,block,timer,除移通知
3. button可以绑定状态来做很多操作(normal,dsiaable)
////////////////////////////////////////////////////////////////////////////////////////////////////////
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define CAREMAINCOLOR RGBCOLOR(86,206,186)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//设置导航颜色
[[UINavigationBarappearance]setBarTintColor:CAREMAINCOLOR];
//导航的“<Back”字体颜色(大多数都是重写)
[[UINavigationBarappearance]setTintColor:[UIColorwhiteColor]];
//设置导航白色字体
[[UINavigationBarappearance]setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:
[UIColorcolorWithRed:245.0/255.0green:245.0/255.0blue:245.0/255.0alpha:1.0],NSForegroundColorAttributeName,
nil,NSShadowAttributeName,
[UIFontfontWithName:@"HelveticaNeue-CondensedBlack"size:21.0],NSFontAttributeName,nil]];;
UINavigationController *navController = [[UINavigationControlleralloc]initWithRootViewController:[[LPViewControlleralloc]init]];
navController.navigationBar.translucent =NO;
//隐藏导航
//[navController setNavigationBarHidden:YES animated:YES];
self.window.rootViewController = navController;
return YES;
}
注意:
iOS7以上系统,self.navigationController.navigationBar.translucent默认为YES,self.view.frame.origin.y从0开始(屏幕最上部)。
此时若是添加代码self.edgesForExtendedLayout = UIRectEdgeNone(iOS7.0以后方法);self.view.frame.origin.y会下移64像素至navBar下方开始。
1.当 navController.navigationBar.translucent =YES;
2.控制器里面
if ([UIDevicecurrentDevice].systemVersion.floatValue>=7.0) {
self.edgesForExtendedLayout =UIRectEdgeNone;
}
解决:(在控制器里面+)
1.方法一
if ([UIDevicecurrentDevice].systemVersion.floatValue>=7.0) {
self.edgesForExtendedLayout =UIRectEdgeNone;
}
2..方法二
navController.navigationBar.translucent =NO;
一般我对导航的重写(base controller)
//// MSCareCustomViewController.m// Care//// Created by linpeng on 14-7-11.// Copyright (c) 2014年 moshi. All rights reserved.//#import "MSCareCustomViewController.h"@interface MSCareCustomViewController ()@end@implementation MSCareCustomViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ [super viewDidLoad]; [self.view setBackgroundColor:[UIColor whiteColor]]; if (iOS_VERSION_NOT_LESS_THAN_7) { self.automaticallyAdjustsScrollViewInsets = NO; } if (self.navigationItem.leftBarButtonItem == nil) { //判别导航的第一个控制器不需要“返回”按钮 if (self.navigationController.viewControllers.count > 1) { NSString *backTitle = @"返回"; [self createAndSetCustomBackButtonWithTitle:backTitle]; } }}-(UIButton *)createAndSetCustomBackButtonWithTitle:(NSString *)title{ UIButton *backButton = [self createCustomBackButtonWithTitle:title]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; [backButton addTarget:self action:@selector(customBackButtonOnclicked:) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.leftBarButtonItem = backItem; return backButton;}-(UIButton *)createCustomBackButtonWithTitle:(NSString *)title{ UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setImage:[UIImage imageNamed:@"ms_care_login_navigationbar_back"] forState:UIControlStateNormal]; [backButton setTitle:[NSString stringWithFormat:@" %@",title] forState:UIControlStateNormal]; [backButton setTitleColor:[UIColor greenColor] forState:UIControlStateSelected]; [backButton.titleLabel setFont:[UIFont systemFontOfSize:15]]; backButton.frame = CGRectMake(0, 0, 100, 30); backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; return backButton;}-(void)customBackButtonOnclicked:(id)sender{ if (self.navigationController) { [self.navigationController popViewControllerAnimated:YES]; }}-(void)removeBackButton{ UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:self action:nil]; self.navigationItem.leftBarButtonItem = backItem;}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}/* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */@end
- iOS 导航栏的一些使用属性记录(备忘)
- iOS:导航栏的属性的一些自定义方法
- iOS--导航栏属性设置的介绍
- iOS导航栏的translucent属性
- IOS 导航栏的 一些用法
- iOS导航栏的一些设置
- ios 导航栏的一些理解
- ios导航栏的使用
- 估计算法的一些记录和备忘
- ios设置导航栏属性
- iOS-修改导航栏属性
- IOS 导航栏属性设置
- ubuntu的一些使用备忘
- ubuntu使用记录(备忘)
- 导航栏跳转和一些常用的属性
- Swift中导航栏的添加与一些属性
- 一些ios的记录
- iOS导航栏使用
- HTML5 Audio/Video 标签,属性,方法,事件汇总
- 函数对象-摘自《C++沉思录》Andrew Koenig
- 网口芯片SMI接口实现
- POJ 2255 二叉树的重建
- 埃迪·加马拉 - 文学经理
- iOS 导航栏的一些使用属性记录(备忘)
- PHP Linux定时任务设置
- 地热发电101
- 经纬财富:辽源市场的变化,需要技术的支持
- 计算机网络(四)
- sprintf函数的用法
- Zend Studio 11 0711 更新破解 11.0.0.v20140715-20140711-1248-184
- Oracle如何导出空表?
- Device eth0 has different MAC address than expected, ignoring.