leftBarButtonItems

在ios 8 下面leftBarButtonItems的位置失败???

?

?

?

? ??//左上角LOGO

? ? UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

? ? [button setImage:[UIImageimageNamed:@"home_title_left_img.jpg"] forState:UIControlStateNormal];

? ? [button setImage:[UIImageimageNamed:@"home_title_left_img.jpg"] forState:UIControlStateHighlighted];

? ? [button addTarget:selfaction:@selector(logoTouchUpInside:) forControlEvents:(UIControlEventTouchUpInside)];

? ? button.showsTouchWhenHighlighted = NO;

? ? [button setFrame:CGRectMake(-100, 8, 80, 28)];

? ? UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:button];

? ? UIBarButtonItem *negativeSpacer = [[UIBarButtonItemalloc]

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? target:nil action:nil];

? ? if (WXHLOSVersion() < 8.0) {

? ? ? ? negativeSpacer.width = -15;

? ? }else{

? ? ? ? negativeSpacer.width = -5;

? ? }

?? ?

? ? self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, leftItem, nil];

我们在ios 6,7下面,可以通过UIBarButtonSystemItemFixedSpace进行,位置的移动
但是今天我升级ios 8下面,这个东西就失败,没有效果了

时间: 2024-08-05 19:10:01

leftBarButtonItems的相关文章

LeftBarButtonItems,定制导航栏返回按钮

? ??UIBarButtonItem *closeBtn = [[UIBarButtonItemalloc] initWithTitle:@"关闭"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(closeAction)]; ? ? UIBarButtonItem *backBtn = [[UIBarButtonItemalloc] initWithTitle:@"返回"style:UIBarB

美团自定义导航栏思路以及代码

一.右边两个图标:直接添加两个UIBarButtonItem,其中各自添加UIButton,然后再设置button的图片,为了方便,使用分类自定义,UIBarButtonItem+DQCategory.h 二.左边加四个UIBarButtonItem,其中各自添加自定义的view,设置好xib的宽高,连个lable,一个按钮button,按钮应该覆盖整个区域以确保整个xib点击都有效果,然后设置按钮靠左对其即可 1.右边图标按钮 分类.h文件 + (UIBarButtonItem *)itemW

UINavigationController

1 #import "AppDelegate.h" 2 #import "RootViewController.h" 3 @interface AppDelegate () 4 5 @end 6 7 @implementation AppDelegate 8 9 10 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc

2016 -1 -3 导航控制器的学习

1.效果如下: 2.UINavigationController,导航控制器也是UIViewController的子类 (1)在Appdelegate.h中 设置UIWindow及其根控制器为导航控制器,代码如下: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customiza

更改导航栏的背景和文字Color

更改导航栏的背景和文字Color方法一: [objc] view plaincopy//set NavigationBar 背景颜色&title 颜色  [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]];  [self.navigationController.navigationBar

多控制器管理

UINavigationController 7.8.1 添加子控制器进栈 UINavigationController *nav = [[UINavigationController alloc] init]; CTOneViewController *one = [[CTOneViewController alloc] init]; //方法一 [nav pushViewController:one animated:YES]; //方法二 [nav addChildViewControll

iOS开发UINavigation系列二——UINavigationItem

iOS开发UINavigation系列二--UINavigationItem 一.引言 UINavigationItem是导航栏上用于管理导航项的类,在上一篇博客中,我们知道导航栏是通过push与pop的堆栈操作来对item进行管理的,同样,每一个Item自身也有许多属性可供我们进行自定制.这篇博客,主要讨论UINavigationItem的使用方法. UINavigationBar:http://my.oschina.net/u/2340880/blog/527706. 二.来说说UINavi

导航状态栏(UINavigationBar)和分栏状态栏(UITabBar)

//*************导航状态栏(UINavigationController)*************** 1.在导航控制器中,所有的子视图控制器共用一个导航状态栏 UINavigationBar *navBar = self.navigationController.navigationBar 2.可设置导航栏的显示风格 navBar.barStyle = UIBarStyleDefault; 3.可设置导航栏的不透明度,默认为YES(不透明) //如果设置为透明,则子视图的左上角

修改UINavigationBar 类

var item:UINavigationItem = UINavigationItem(); var viewTitle = UIView(); viewTitle.backgroundColor = UIColor.redColor(); viewTitle.frame = CGRectMake(0, 0, 20, 30) item.titleView = viewTitle; var button:UIBarButtonItem = UIBarButtonItem(title: "Left