hi, i want to append two label texts(which are in different colors) in One label.any help please? how can i do it?
+1
A:
you can use one UILabel with two other UILabels with their own setups as a subviews. smth like this
UILabel* mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 120, 40)]; UILabel* firstSublabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 40)]; [firstSublabel setText:@"asd"]; [firstSublabel setTextColor:[UIColor redColor]]; [mainLabel addSubview:firstSublabel]; [firstSublabel release]; UILabel* secondSublabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, 60, 40)]; [secondSublabel setText:@"dfg"]; [secondSublabel setTextColor:[UIColor greenColor]]; [mainLabel addSubview:secondSublabel]; [secondSublabel release]; [self.view addSubview:mainLabel]; [mainLabel release];
Morion
2009-12-03 11:35:14
will u give any tutorial link pls?
Mikhail Naimy
2009-12-03 11:44:23
A:
Not really in a nice way.
There are some ideas for replacements in this question: Why is there no NSAttributedString
on the iPhone?
Georg
2009-12-03 11:38:30