UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(-10,0,scrrenW*0.05,44)];
[leftBtn setBackgroundImage:[UIImage imageNamed:@"btnBack"] forState:UIControlStateNormal];
leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[leftBtn setTitleColor:totalColor forState:UIControlStateNormal];
leftBtn.titleLabel.font= [UIFont systemFontOfSize:40];
[leftBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButton Itemalloc] initWithCustomView:leftBtn];
UIBarButtonItem *negativeSpacer1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
negativeSpacer1.width= -20;//这个数值可以根据情况自由变化
self.navigationItem.leftBarButtonItems=@[negativeSpacer, item];// 解决左边按钮靠左的问题,****右边按钮可以用同样的方法解决
注:不喜勿喷!!!
网友评论