1. 程式人生 > >三步教你iOS匯入.ttf字型檔案

三步教你iOS匯入.ttf字型檔案

1.首先info.plist中加入屬性Fonts provided by application,在item 0 處填寫匯入的ttf檔名

2.查出你匯入字型的font name    

NSArray * fontArrays = [[NSArray alloc] initWithArray:[UIFont familyNames]];
    for (NSString * temp in fontArrays) {
        NSLog(@"Font name  = %@", temp);
    }

3.就是這樣簡單的用了唄

    UILabel * tempTwoLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 40)];
    UIFont * fontTwo = [UIFont fontWithName:@"DFPWaWaW5-GB" size:15];
    [tempTwoLabel setFont:fontTwo];
    [tempTwoLabel setText:@"這是新字型——ONe----->華康娃娃體"];
    [self.view addSubview:tempTwoLabel]