Bootstrap

调整navigationBar按钮的位置

按照一般的方法创建导航栏的左右按钮时,会出现按钮向里偏的现象,但有时想让按钮往屏幕边靠怎么办呢?


1.首先先创建按钮


    UIButton *button = [[UIButton alloc] init];
    [button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateHighlighted];
    button.size = button.currentBackgroundImage.size;
    [button addTarget:self action:@selector(ABC) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *barBtn  = [[UIBarButtonItem alloc] initWithCustomView:button];

2.创建个UIBarButtonSystemItemFixedSpace的UIBarButtonItem,并设置间距

    UIBarButtonItem *
;