标签:
效果如下:
ViewController.h
1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UITableViewController 4 @property (strong, nonatomic) NSArray *arrFontName; 5 @property (strong, nonatomic) NSArray *arrFont; 6 @property (strong, nonatomic) NSDictionary *dicFontSize; 7 8 @end
ViewController.m
1 #import "ViewController.h" 2 3 @interface ViewController () 4 - (void)layoutUI; 5 @end 6 7 @implementation ViewController 8 9 - (void)viewDidLoad { 10 [super viewDidLoad]; 11 12 [self layoutUI]; 13 } 14 15 - (void)didReceiveMemoryWarning { 16 [super didReceiveMemoryWarning]; 17 // Dispose of any resources that can be recreated. 18 } 19 20 - (void)layoutUI { 21 self.navigationItem.title = @"显示系统中的字体"; 22 23 CGFloat fontSize = [UIFont systemFontSize]; //[UIFont systemFontSize]=14 24 _arrFontName = @[@"System Font Size", 25 @"Small System Font Size", 26 @"Bold System Font Of Size", 27 @"Italic System Font Of Size", 28 @"Button Font Size", 29 @"Label Font Size"]; 30 _arrFont = @[[UIFont systemFontOfSize:fontSize], 31 [UIFont systemFontOfSize:[UIFont smallSystemFontSize]], //[UIFont smallSystemFontSize]=12 32 [UIFont boldSystemFontOfSize:fontSize], 33 [UIFont italicSystemFontOfSize:fontSize], 34 [UIFont systemFontOfSize:[UIFont buttonFontSize]], //[UIFont buttonFontSize]=18 35 [UIFont systemFontOfSize:[UIFont labelFontSize]]]; //[UIFont labelFontSize]=17 36 37 _dicFontSize = @{_arrFontName[0] : @"14", 38 _arrFontName[1] : @"12", 39 _arrFontName[2] : @"14", 40 _arrFontName[3] : @"14", 41 _arrFontName[4] : @"18", 42 _arrFontName[5] : @"17", 43 }; 44 } 45 46 #pragma mark - TableView 47 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 48 return nil; 49 } 50 51 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 52 return 1; 53 } 54 55 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 56 return [_arrFontName count]; 57 } 58 59 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 60 static NSString *cellIdentifier = @"cellIdentifier"; 61 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 62 if (!cell) { 63 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 64 } 65 66 NSInteger row = indexPath.row; 67 cell.textLabel.text = [NSString stringWithFormat:@"%@ (fontSize:%@)", 68 _arrFontName[row], 69 [_dicFontSize objectForKey:_arrFontName[row]]]; 70 cell.textLabel.font = _arrFont[row]; 71 return cell; 72 } 73 74 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 75 76 } 77 78 @end
AppDelegate.h
1 #import <UIKit/UIKit.h> 2 3 @interface AppDelegate : UIResponder <UIApplicationDelegate> 4 @property (strong, nonatomic) UIWindow *window; 5 @property (strong, nonatomic) UINavigationController *navigationController; 6 7 @end
AppDelegate.m
1 #import "AppDelegate.h" 2 #import "ViewController.h" 3 4 @interface AppDelegate () 5 @end 6 7 @implementation AppDelegate 8 9 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 10 _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 11 ViewController *viewController = [[ViewController alloc] init]; 12 _navigationController = [[UINavigationController alloc] initWithRootViewController:viewController]; 13 _window.rootViewController = _navigationController; 14 //[_window addSubview:_navigationController.view]; //当_window.rootViewController关联时,这一句可有可无 15 [_window makeKeyAndVisible]; 16 return YES; 17 } 18 19 - (void)applicationWillResignActive:(UIApplication *)application { 20 } 21 22 - (void)applicationDidEnterBackground:(UIApplication *)application { 23 } 24 25 - (void)applicationWillEnterForeground:(UIApplication *)application { 26 } 27 28 - (void)applicationDidBecomeActive:(UIApplication *)application { 29 } 30 31 - (void)applicationWillTerminate:(UIApplication *)application { 32 } 33 34 @end
标签:
原文地址:http://www.cnblogs.com/huangjianwu/p/4581486.html