Add two additional button buttons that use the UIBarButtonSystemItemFlexibleSpace system style and place them between each of the existing buttons:
[self.navigationController setToolbarHidden:NO]; UIImage *buttonImage1 = [UIImage imageNamed:@"1"]; UIImage *buttonImage2 = [UIImage imageNamed:@"2"]; UIImage *buttonImage3 = [UIImage imageNamed:@"3"]; UIBarButtonItem *toolButton1 = [[UIBarButtonItem alloc] initWithImage:buttonImage1 style:UIBarButtonItemStylePlain target:self action:@selector(btnSettingsClick:)]; UIBarButtonItem *toolButton2= [[UIBarButtonItem alloc] initWithImage:buttonImage2 style:UIBarButtonItemStylePlain target:self action:@selector(btnSettingsClick:)]; UIBarButtonItem *toolButton3 = [[UIBarButtonItem alloc] initWithImage:buttonImage3 style:UIBarButtonItemStylePlain target:self action:@selector(btnSettingsClick:)]; [self setToolbarItems:[NSArray arrayWithObjects: toolButton1, [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], toolButton2, [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], toolButton3, nil]];
This is strange for conceptualization, but flexible space is actually a separate object, not a style to apply to other objects.
jszumski
source share