Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
i added a toolbar and made it translucent (Bottom) of the screen. now i want to change it's title. i tried so many ways but none worked and it seems that title isn't a property that is included for translucent toolbars. i tried to add a UILabel and it also didn't work cause i couldn't place a Label on a translucent toolbar in the first place. how can i do that?
 

waterskier2007

macrumors 68000
Jun 19, 2007
1,871
228
Novi, MI
Are you talking about a toolbar or navigation bar. Navigation bars contain the title property of the view controller itself. The title property is not part of the navigation bar.

As for toolbars, I am not sure how or why you would want to set a title on it, as toolbars are for interacting with things like buttons/sliders/etc.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
i added a toolbar and made it translucent (Bottom) of the screen. now i want to change it's title. i tried so many ways but none worked and it seems that title isn't a property that is included for translucent toolbars. i tried to add a UILabel and it also didn't work cause i couldn't place a Label on a translucent toolbar in the first place. how can i do that?

As you've discovered, there is no title property for UIToolbar. So, perhaps instead of telling us what you think is the solution, you could tell us what problem you're trying to solve and maybe we can come up with some alternatives.
 

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
As you've discovered, there is no title property for UIToolbar. So, perhaps instead of telling us what you think is the solution, you could tell us what problem you're trying to solve and maybe we can come up with some alternatives.

i already stated that, i want to set a title for a translucent toolbar (the one below and not the navigation bar). I've seen it before in some apps where some info is shown below beside being used by tools buttons and stuff. actually the one i saw was being used on a normal blue backgrounded toolbar. so is it possible?
 

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
Yes. Since UIToolbar is a UIView subclass, one approach to consider is just adding a subview to it.

i found a way to do that. i added two flexible spaces and one item. i placed the item in the middle and the spaces to the left/right of it. i created an outlet property for the item so that i can change it's text in code. and i changed it's style to plain so that it looks like a label not a button. However, i still have one problem (which isn't a major issue though but it's annoying me). when i run the app everything works fine but if i press on the item a white spot appears tracking my tapping gesture. how can i remove that? i searched the documentation and i couldn't find any thing related to recognizing gestures for items. help please ? or direct me to the documentation if i missed anything (i know you're not straightforward with your answers haha) thanks anyway.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,558
6,058
i found a way to do that. i added two flexible spaces and one item. i placed the item in the middle and the spaces to the left/right of it. i created an outlet property for the item so that i can change it's text in code. and i changed it's style to plain so that it looks like a label not a button. However, i still have one problem (which isn't a major issue though but it's annoying me). when i run the app everything works fine but if i press on the item a white spot appears tracking my tapping gesture. how can i remove that? i searched the documentation and i couldn't find any thing related to recognizing gestures for items. help please ? or direct me to the documentation if i missed anything (i know you're not straightforward with your answers haha) thanks anyway.

The item should have an "enabled" property. Set it to false and it should stop tracking touches.
 

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
The item should have an "enabled" property. Set it to false and it should stop tracking touches.

i tried that before but it fades into the background.i want it to still be there and clear but no recognition should be there. thanks.

----------

Glad you figured it out! :)

:). any hints on the post that i posted earlier?
 

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
You replaced a UIBarButtonItem with a UILabel? How'd you manage that?

You're welcome. And thank you for the compliment.

You're welcome! okay i'll be better than you, i'm not going to be beating around the bush (JK). here is the code:

Code:
SSCustomLabel *label = [[SSCustomLabel alloc] initWithFrame:CGRectMake(140 , 0, 50, 250)];
    label.text = [NSString stringWithFormat:@"%.2f", [self someMethod]];
    UIView *view = (UIView *) label;
    [self.barItem setCustomView:view];

what i did is created a new class which is a subclass of UILabel (actually you don't have to do that but since i'll be customising the text font and colour and stuff, i made it that way just so my code looks cleaner). i then instantiated an object with a CGrect parameters. next put a text in it. then (the trick) assign the label casted as a UIView to an instant of UIView and after that use the setCustomView function to set the view over the item that you added in the interface builder. (barItem is a UIBarButtonItem)
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Ah, so you didn't really replace a UIBarButtonItem with a UILabel. You just set the customView property of the item to the UILabel. Got it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.