Last active
December 17, 2015 14:19
-
-
Save jblocksom/5623153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BNRPerson.h | |
// SalesReport | |
// | |
// Created by Jonathan Blocksom on 4/1/13. | |
// Copyright (c) 2013 Jonathan Blocksom. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface BNRPerson : NSObject | |
@property (copy) NSString *name; | |
@property NSUInteger sales; | |
@property (readonly) UIImage *photo; | |
- (id)initWithName:(NSString *)name image:(UIImage *)image; | |
// Initializes object with specified properties; if image | |
// is nil, will try to load image named same thing as name | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BNRPerson.m | |
// SalesReport | |
// | |
// Created by Jonathan Blocksom on 4/1/13. | |
// Copyright (c) 2013 Jonathan Blocksom. All rights reserved. | |
// | |
#import "BNRPerson.h" | |
@interface BNRPerson() | |
@property (strong, readwrite) UIImage *photo; | |
// Declaring photo property readwrite here and as | |
// readonly in the .h file means we can modify it | |
// in the implementation but a user of the class | |
// cannot change it. | |
@end | |
@implementation BNRPerson | |
- (id)initWithName:(NSString *)name image:(UIImage *)image | |
{ | |
self = [super init]; | |
if (self) { | |
self.name = name; | |
if (image != nil) { | |
self.photo = image; | |
} else { | |
self.photo = [UIImage imageNamed:name]; | |
} | |
} | |
return self; | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Figure out the font | |
CTFontRef nameFont = CTFontCreateWithName(CFSTR("Palatino-BoldItalic"), NAME_HEIGHT, NULL); | |
// Get the glyphs | |
CGGlyph *gBuffer = malloc(length * sizeof(CGGlyph)); | |
CTFontGetGlyphsForCharacters(nameFont, cBuffer, gBuffer, length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment