Search code examples
xcodeuitextviewtag-cloud

Is it possible to have variable text sizes in UITextView? (Making a tag cloud)


I would like to create a tag cloud of sorts, and I thought of using a UITextView. Is it possible to have variable text sizes in a UITextView? If not, any other suggestions on which UI elements to use to generate a tag cloud?


Solution

  • I would recommend programmatically adding UILabel objects as needed. You can only have one font size per UITextView, plus UITextView is generally for editable text. Just roughly, you could use something like this:

     UILabel *example = [[UILabel alloc] initWithFrame:<#(CGRect)#>];
     [example setFont:<#(UIFont *)#>];
     [example setText:<#(NSString *)#>];
     [self.view addSubview:example];
    

    You can put it in a loop and fill in the blanks.