-1

I have a DetailView Controller that is being pushed from a UITableView Controller. What I am trying to do is change the font of the title when it is pushed from the UITableViewController. I will show you the lines of code for my segue where I am doing it.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//push segue identifier 'showArrayDetail'
if ([[segue identifier] isEqualToString:@"ShowDetail"])
{
    NSString *object = nil;

    [[segue destinationViewController] setDetailLabelContents:object];

    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    DetailViewController *destViewController = segue.destinationViewController;
    destViewController.climbName = climbs[indexPath.row];
    destViewController.title = [NSString stringWithFormat:@"%@ Details", destViewController.climbName];

    destViewController.title = [UIFont fontWithName:@"Chalkduster" size:17];
}

}

The very last line is where I am trying to change the font, it is giving me this warning:

FourthTableViewController.m:134:34: Incompatible pointer types assigning to 'NSString *' from 
'UIFont *

Is there a way to parse the title or a way around this? I am doing this same method when changing my font inside my UITableViews, etc. It just doesn't like when you do it to the title.

Thanks

javaGeek
  • 304
  • 1
  • 4
  • 11
  • What is the property title? UILabel or NSString? – Nate Lee May 17 '14 at 23:05
  • 1
    You can't set a font to an NSString, only a NSAttributedString or whatever which has the font property. Theres an answer below which involves attributed strings – Nate Lee May 17 '14 at 23:08
  • Check this http://stackoverflow.com/questions/5832036/change-the-navigation-bars-font – HMHero May 17 '14 at 23:16

1 Answers1

0

You actually can't change a font like that. You just created new instance of UIFont, not an NSString instance. You need to read about attributed strings more here. Example:

NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:14.0];
NSDictionary *attrsDictionary =
        [NSDictionary dictionaryWithObject:font
                                    forKey:NSFontAttributeName];
NSAttributedString *attrString =
    [[NSAttributedString alloc] initWithString:@"strigil"
            attributes:attrsDictionary];
sunshinejr
  • 4,834
  • 2
  • 22
  • 32