标签:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
/**
* 设置frame只能控制按钮的大小
*/
btn.frame= CGRectMake(0, 0, 40, 44);
[btn addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btn_right = [[UIBarButtonItem alloc] initWithCustomView:btn];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
/**
* width为负数时,相当于btn向右移动width数值个像素,由于按钮本身和边界间距为5pix,所以width设为-5时,间距正好调整
* 为0;width为正数时,正好相反,相当于往左移动width数值个像素
*/
negativeSpacer.width = -5;
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, btn_right, nil];
[btn_right release];
调整导航条上leftBarButtonItem和rightBarButtonItem与屏幕边界的间距
标签:
原文地址:http://www.cnblogs.com/helmsyy/p/5424271.html