ios自定义标签不支持字体系列仅支持Lucida Grande?

时间:2013-02-28 05:45:57

标签: iphone ios objective-c uilabel xcode4.5

我正在使用Lucida Grande字体系列,它工作正常。

FontLabel *label4 = [[FontLabel alloc] initWithFrame:CGRectMake(10, 6, 250, 50)];
        ZMutableAttributedString *str = [[ZMutableAttributedString alloc] initWithString:cmd_string
                                                                              attributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                                          [[FontManager sharedManager] zFontWithName:@"Lucida Grande" pointSize:12],
                                                                                          ZFontAttributeName,
                                                                                          nil]];
        label4.backgroundColor=[UIColor clearColor];
        [str addAttribute:ZFontAttributeName value:[[FontManager sharedManager] zFontWithName:@"Lucida Grande" pointSize:12] range:NSMakeRange(0, name_length)];
        [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:241/255.0f green:73.0/255.0f blue:2.0/255.0f alpha:1.0]range:NSMakeRange(0, name_length)];
        [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:128.0/255.0f green:121.0/255.0f blue:98.0/255.0f alpha:1.0]range:NSMakeRange(name_length, cmd_str_len-name_length)];
        label4.zAttributedText = str;
        label4.numberOfLines=0;
        [label4 sizeToFit];

我正在使用Helvetica-Bold字体系列,它无法使用app crahing,请帮帮我。

FontLabel *label4 = [[FontLabel alloc] initWithFrame:CGRectMake(10, 6, 250, 50)];
        ZMutableAttributedString *str = [[ZMutableAttributedString alloc] initWithString:cmd_string
                                                                              attributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                                          [[FontManager sharedManager] zFontWithName:@"Helvetica-Bold" pointSize:12],
                                                                                          ZFontAttributeName,
                                                                                          nil]];
        label4.backgroundColor=[UIColor clearColor];
        [str addAttribute:ZFontAttributeName value:[[FontManager sharedManager] zFontWithName:@"Helvetica-Bold" pointSize:12] range:NSMakeRange(0, name_length)];
        [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:241/255.0f green:73.0/255.0f blue:2.0/255.0f alpha:1.0]range:NSMakeRange(0, name_length)];
        [str addAttribute:ZForegroundColorAttributeName value:[UIColor colorWithRed:128.0/255.0f green:121.0/255.0f blue:98.0/255.0f alpha:1.0]range:NSMakeRange(name_length, cmd_str_len-name_length)];
        label4.zAttributedText = str;
        label4.numberOfLines=0;
        [label4 sizeToFit];

1 个答案:

答案 0 :(得分:1)

Lucinda Grande在iOS中不可用,仅适用于Mac OS X.