UIFont *font=[UIFont fontWithName:@"Arial" size:16.0];
    
    NSString *str=[[NSString alloc] initWithString:@"Hello"];
    [str drawAtPoint:CGPointMake(100, 100) withFont:font];
    [str release];
输出的Hello,为白色,如何设置字体颜色

解决方案 »

  1.   

    不知道你要在什么上面显示这个NSString呢?设置颜色一般是会有textColor,color之类的属性的
    比如你要显示在label上面  label就有一个textColor属性的
      

  2.   

    NSString是字串类,与显示无关,
    颜色在drawAtXX方法里设置,
    或是用UILabel,UITextView之类的,有textColor或color的属性可以设置
    - (void) drawRect:(CGRect) rect {    NSString *hello   = @"Hello, World!";    CGPoint  location = CGPointMake(10, 20);    UIFont   *font    = [UIFont systemFontOfSize:24.0];    [[UIColor whiteColor] set];    [hello drawAtPoint:location withFont:font];}