Is it possible to have variable text sizes in UITextView? (Making a tag cloud)
-
29-06-2021 - |
سؤال
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?
المحلول
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.
نصائح أخرى
It should be possible in iOS 6 (if you can wait that long) since Apple is finally adding the possibility to use NSAttributedString
in UITextView
.
لا تنتمي إلى StackOverflow