3

Ok I was looking at the iPhone iCal app, and was curious whether that top bar is a navigation bar or a toolbar? ive tried using both, but also i cannot figure out how to change the size of the buttons to be as small as the + button in the top right... very confused.. I'm assuming its a navigation bar, but when i read the description of the navigation bar, it said that whenever you are to add a button or item onto the bar, you cannot connect it directly... no idea how else to do it... but anyone wanna help with this issue?

trludt
  • 1,801
  • 2
  • 13
  • 15
  • can you please post some screenshots? – DD_ Dec 17 '12 at 06:01
  • How do i put up screenshots? @Dpk – trludt Dec 17 '12 at 06:10
  • http://productivebydesign.free.fr/wp-content/images/iphone_calendar.png There is a pic of the calendar app in the iPhone.. im talking about the top bar.. what kind of bar is it, and read the rest of the post ^^ @Dpk – trludt Dec 17 '12 at 06:17

3 Answers3

3

If you are mentioning about this one It is not UITabBar , it is UINavigationBar, the button on extreme left is inbuilt backbutton of UINavigationBar and the that at right is an extra button that you can add , its clearly shown in this question , and to change the type (ie, + button) you can simply change the button style using

 UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                    style:UIBarButtonSystemItemAdd target:nil action:nil];

adding button to UINavigationBar

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
    style:UIBarButtonSystemItemAdd target:nil action:nil];
rightButton.width=10;
rightButton.height=10;
    UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"];
    item.rightBarButtonItem = rightButton;
    item.hidesBackButton = YES;
    [bar pushNavigationItem:item animated:NO];
    [rightButton release];
    [item release];

But normally you would have a navigation controller, enabling you to write:

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
    style:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];

Hope this helps, regards

Community
  • 1
  • 1
DD_
  • 7,230
  • 11
  • 38
  • 59
  • That works.. I am just wondering how to change the size of that button?? i'm not sure how to change the width of a bar button item... @Dpk – trludt Dec 17 '12 at 20:01
  • @trludt you can adjust the width and height of UIBarButtonItem,using buttton.width and button .height property, check my updated answer, and kindly accept it if it helps, thanks – DD_ Dec 18 '12 at 04:30
2

enter image description here

The top bar with RED circle is UINavigationaBar & the bar with GREEN circle is custom designed. You can the use the below written code to add the system defined Add button to UINavigationaBar

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                    style:UIBarButtonSystemItemAdd target:nil action:nil];
hp iOS Coder
  • 3,230
  • 2
  • 23
  • 39
  • Do you know how to shrink the button size? to be like the + button in the top right corner on the navigation bar. I know it has to be a bar button item, but i can't figure out how to change the size of it.. help? @hpIOSCoder – trludt Dec 17 '12 at 16:33
0

I realized that in fact you do not need code to get the button to shrink to the size of the + button in the top right corner of the calendar app. In fact, once you are in the storyboard. Open up the utilities tab on the right. Then open the attributes inspector. and where it says Identifier, the drop down tab has options. Choose the add option.

trludt
  • 1,801
  • 2
  • 13
  • 15