My problem is following: i want to know the coordinates to an item of a toolbar so that i could pop some data right there. These barbuttonitems never reveal me there frame properties.
Is there a solution?
Asked
Active
Viewed 139 times
3 Answers
0
You can use if you want to give spacing.
UIBarButtonItem *fixedLeftSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
// for adding Custom view
UIButton *webButton = [UIButton buttonWithType:UIButtonTypeCustom];
[webButton setFrame:CGRectMake(0, 0, 50, 40)];
[webButton setImage:[UIImage imageNamed:@\"webIcon.jpg\"] forState:UIControlStateNormal];
[webButton addTarget:self action:@selector(goToWebPage) forControlEvents:UIControlEventTouchDown];
UIBarButtonItem *webpageBtn = [[UIBarButtonItem alloc]initWithCustomView:webButton];
[webpageBtn setTarget:self];
[webpageBtn setAction:@selector(goToWebPage)];
[toolbar setItems:[NSArray arrayWithObjects: webpageBtn,fixedLeftSpace,webpageBtn, nil]];
Also see the link.

Community
- 1
- 1

HDdeveloper
- 4,396
- 6
- 40
- 65
0
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 210, 44)];
UIBarButtonItem *space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithObjects:bt1,space,bt2,space,bt3, nil];
[tools setItems:buttons animated:YES];
UIBarButtonItem *toolsBtn = [[UIBarButtonItem alloc]initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = toolsBtn;

NANNAV
- 4,875
- 4
- 32
- 50
0
If you are creating a toolbar from xib file then you need to add multiple "flexible space bar button item" before and after the buttons if you multiple bar buttons on toolbar until you get the desired spacing. If you are creating UIToolbar dynamically then you need to add flexible buttons dynamically.

ask4asif
- 676
- 4
- 10