question about the use of TTLabel
I find TTLabel in Three20 and in my thought it is the one like UILabel.However TTLabel only has two properties:text and font. How about the textColor? I add a TTLable in a view,and the code is like
TTLabel *_ttLabel = [[TTLabel alloc] initWithText:@"ttlabel"];
_ttLabel.frame = CGRectMake(10, 50, 50, 50);
_ttLabel.backgroundColor = [UIColor whiteColor];
[s开发者_开发技巧elf.view addSubview:_ttLabel];
TT_RELEASE_SAFELY(_ttLabel);
Then in my view, I just find a white rectangle. So I want to know what is the use of TTLabel? And How can I use it to show info just like UILabel. (Or May I am totally wrong: TTLael is an abstract class?)
thanks
TTLabel
is a styled label. So there is no textColor property because you set that as part of your string (just like normal HTML).
if you use TTLabel, the style property must be set.
I have also encountered a problem just like yours. I opted for the TTLabel since you can format it by using the TTView's style
property, but was disappointed when I found I can't seem to output the text.
My workaround to this problem was to have a TTView to hold the styling, then use a standard UILabel for any text content you may want to have. The limitation to this approach is that your styling may not dynamically resize to accomodate the possible large text value. This worked for me since my use for this is the same as facebook's notification count(that red circle with a number on it).
here's the code by the way:
TTStyle *style =
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED]
next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1.5, 1.5, 1.5, 1.5)
next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.8) blur:3 offset:CGSizeMake(0, 5) next:
[TTReflectiveFillStyle styleWithColor:[UIColor redColor] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-1.5, -1.5, -1.5, -1.5) next:
[TTSolidBorderStyle styleWithColor:[UIColor whiteColor] width:3 next:nil]]]]]];
and:
TTView* myView = [[[TTView alloc] initWithFrame:CGRectMake(220, 360, 40,40)] autorelease];
myView.backgroundColor = [UIColor clearColor];
myView.style = style;
UILabel* badge = [[[UILabel alloc] initWithFrame:CGRectMake(220, 355, 40,40)]autorelease];
badge.text = @"1";
badge.textColor = [UIColor whiteColor];
badge.textAlignment = UITextAlignmentCenter;
badge.backgroundColor = [UIColor clearColor];
badge.font = [UIFont boldSystemFontOfSize:17];
[self.view addSubview:myView];
[self.view addSubview:badge];
精彩评论