Reputation: 5993
I am trying to use https://github.com/honcheng/RTLabel to get a rich text label, but my immediate goal is to display "Hello, world!"
My code is:
UIImageView *noteImage = [[UIImageView alloc] initWithFrame:bounds];
noteImage.image = image;
[self.view addSubview:noteImage];
CJSHCardView *noteView = [[CJSHCardView alloc] initWithImage:image];
[noteView setFrame:CGRectMake(100 * i, 20, 100 * scale, 100 * scale)];
noteView.transform = CGAffineTransformScale(noteView.transform, scale_x, scale_y);
NSString *text = @"Hello, world!";
RTLabel *label = [[RTLabel alloc] initWithFrame:CGRectMake(100 * i, 20, 100 * scale, 100 * scale)];
[noteImage addSubview:label];
[label setText:text];
I tried both noteImage and noteView in the second-to-last line. The rectangle has the same dimensions as the original image, which is displaying correctly. However, none of the approaches I've tried seem apt to display a label on top of the noteImage / noteView as backgrounds.
What is an appropriate way to get a label (preferably one that supports rich text) to display on top of an image meant to serve as background for it?
Upvotes: 0
Views: 390
Reputation: 3154
iOS 7's UILabel supports attributed strings, so unless you need to target an earlier version, I suggest simply building your UI in interface builder and setting the attributed text as needed in your code.
Upvotes: 1