UILabel - setting font - typeface programmatically in iPhone

后端 未结 6 957
谎友^
谎友^ 2020-12-05 02:40

I have following code in my Application.

tmp=[[UILabel alloc] initWithFrame:label1Frame];
tmp.tag=1;
tmp.textColor=[UIColor blackColor];
[tmp setFont:[UIFont         


        
6条回答
  •  一整个雨季
    2020-12-05 03:28

    Just NSLog The font you want get:

    NSLog(@" %@", [UIFont fontNamesForFamilyName:@"American Typewriter"]);
    

    And you get the array:

    (
        "AmericanTypewriter-CondensedLight",
        "AmericanTypewriter-Light",
        "AmericanTypewriter-Bold",
        AmericanTypewriter,
        "AmericanTypewriter-CondensedBold",
        "AmericanTypewriter-Condensed"
    )
    

    Use any you need in Code:

    UILabel * loading = [[UILabel alloc] initWithFrame:CGRectMake(350, 402, 150, 25)];
        [loading setFont:[UIFont fontWithName:@"AmericanTypewriter-Bold" size:12.0]];
        [loading setTextColor:[UIColor whiteColor]];
        [loading setBackgroundColor:[UIColor clearColor]];
        [loading setText:@"Loading ..."];
        [self.view addSubview:loading];
    

提交回复
热议问题