i want to append two label texts(which are in different colors) in One label.any help please? how can i do it?
Asked
Active
Viewed 174 times
2 Answers
0
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
- 10,495
- 1
- 24
- 33
-
will u give any tutorial link pls? – Dec 03 '09 at 11:44
0
Not really in a nice way.
There are some ideas for replacements in this question: Why is there no NSAttributedString
on the iPhone?

Community
- 1
- 1

Georg Schölly
- 124,188
- 49
- 220
- 267