You'll have to create a plist of all the font names. The names can be found here:
iOS Fonts.
Then what I would do is create a category on UIFont and add a method called knownFontNames or systemFontNames. Have it create an array from the plist and return it.
Then, I'd create a view controller named FontPickerController or something like that. In that controller, retrieve the font names array and use it to populate 1 UIPickerView. Then, create a loop and add NSNumber objects. Something like this:
Code:
int i = 1;
int maxFontSize = 72;
NSMutableArray *fontSizes = [[NSMutableArray alloc] initWithCapacity:maxFontSize];
for (i = 1; i < maxFontSize; i++) {
NSNumber *fontSize = [NSNumber numberWithInt:i];
[fontSizes addObject:fontSize];
}
Then use that array to populate the second UIPickerView. You'll have convert the NSNumber objects to string first though which isn't that hard:
Code:
NSString *numberString = [NSString stringWithFormat:@"%i", [aNSNumberObject intValue]];
The %i is a format code, in this case it's the format code for an integer. With format codes, you can create dynamic strings.
I'm guessing you want to use these fonts in some way, so I'd go with delegation so that you can reuse this font picker in the future. Explaining how to setup a delegate is going to be a little bit too long for this post but there are a bunch of tutorials online. And you'd probably want to use the delegate for other things like specifying the max font size so you don't have to modify your font picker if you want to say change the max font size to 80 instead of 72.
Hope that helps.
Edit: And if you are only targeting iOS 5+, you should use a UIStepper control instead of a UIPickerView to have the user choose the font size.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com.
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.