(iPhone iPad)
- (void)getAllFonts{
NSArray *fontFamilies =[UIFont familyNames];
for(int i =0; i <[fontFamilies count]; i++){
NSString *fontFamily =[fontFamilies objectAtIndex:i];
NSArray *fontNames =[UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]];
NSLog(@"%@: %@", fontFamily, fontNames);
}
}
/ [self getAllFonts];
EDIT: , ,
1:
@interface FontViewController (){
NSArray* fontFamilies;
}
2: (.m) viewDidLoad.
-(void)viewDidLoad{
fontFamilies = [UIFont familyNames];
}
STEP3: , cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [fontFamilies objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont fontWithName:[fontFamilies objectAtIndex:indexPath.row] size:12];
return cell;
}
PS: , . tableView Cell ( xib) "Cell", , :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return fontFamilies.count;
}
, Apple
. AppCoda