加入DFLiuStd-W3.otf
2. 設定Font provided by application
於其中輸入字型檔的檔名
3. 設定Label的font
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (NSString *familyName in [UIFont familyNames]) | |
{ | |
NSLog(@"familyName %@", familyName); | |
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) | |
{ | |
NSLog(@"%@", fontName); | |
} | |
} | |
UILabel *bookLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 300, 30)]; | |
[self.view addSubview:bookLabel]; | |
bookLabel.text = @"App程式設計入門"; | |
UILabel *authorLabel = [[UILabel alloc] initWithFrame:CGRectMake(160, 60, 120, 30)]; | |
[self.view addSubview:authorLabel]; | |
authorLabel.text = @"彼得潘"; | |
UIFont *newFont = [UIFont fontWithName:@"DFLiuStd-W3" size:30]; | |
bookLabel.font = newFont; | |
authorLabel.font = newFont; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize; |
我們利用fontNamesForFamilyName:列出所有的font,
從中找到DFLiuStd-W3。
執行App:
沒有留言:
張貼留言