Styling a TTLauncherItem

112 views
Skip to first unread message

travio

unread,
Dec 9, 2009, 4:33:00 AM12/9/09
to Three20
Hi Three20,

I'm trying to style a TTLauncherItem so that the text colour of the
label is black, not the default gray. I realise there's a "style"
property on the TTLaunchItem, but I don't know how to use it further
than item.style = @"aStyle".

Is there any doco or examples of this? I've had a bit of a dig around
but I haven't found anything useful :(

ta.

Emil

unread,
Dec 9, 2009, 4:35:32 AM12/9/09
to thr...@googlegroups.com
You should always specify a style with a TTStyle object.


item.style = [TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:3] next:nil]

for ex.

//Emil
> --
>
> You received this message because you are subscribed to the Google Groups "Three20" group.
> To post to this group, send email to thr...@googlegroups.com.
> To unsubscribe from this group, send email to three20+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/three20?hl=en.
>
>

travio

unread,
Dec 9, 2009, 4:47:16 AM12/9/09
to Three20
Thanks for the quick reply.

Unless I'm using an old version of three20 (i don't think i am,
grabbed it last week), TTLauncherItem's style property is a string:

TTLauncherItem.h:19
@property(nonatomic,copy) NSString* style;

If I do try setting the style property on the TTLauncherItem with a
TTTextStyle, Xcode warns that I'm not using the correct type, and when
I run the project, it dies when it tries to set the property. eg
this code will die on the second line

TTLauncherItem *item = [[TTLauncherItem alloc] initWithTitle:@"Item"
image:@"bundle://image.png" URL:@"tt://item"];
item.style = [TTTextStyle styleWithColor:[UIColor blackColor]
next:nil];

Any ideas?

Emil

unread,
Dec 9, 2009, 4:49:21 AM12/9/09
to thr...@googlegroups.com
Ah yes sorry.
the string in this case is used for a selector inside the code.

so basicly it uses the
item.style for @selector(item.style)

And the selector is executed on the TTGlobalStylesheet.

If im not misstaken.

//Emil

Sascha Konietzke

unread,
Dec 9, 2009, 5:28:25 AM12/9/09
to Three20
Create your own MyCustomStylesheet that inherits from
TTDefaultStyleSheet. Enabled it globally by [TTStyleSheet
setGlobalStyleSheet: [[[MyCustomStylesheet alloc] init] autorelease]].
This has the advantage that you can use it for many more style
customizations.

In your MyCustomStylesheet override the following method:

- (TTStyle*)launcherButton:(UIControlState)state {
return
[TTPartStyle styleWithName:@"image" style:TTSTYLESTATE
(launcherButtonImage:, state) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:11]
color:RGBCOLOR(180, 180, 180)
minimumFontSize:11 shadowColor:nil
shadowOffset:CGSizeZero next:nil]];
}

The RGBCOLOR part should be what you are looking for.

travio

unread,
Dec 9, 2009, 9:05:17 AM12/9/09
to Three20
Awesome thanks all for the help.
Reply all
Reply to author
Forward
0 new messages