Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)drawRect:(NSRect)dirtyRect
- {
- NSFont *font = [NSFont fontWithName:@"Zapfino" size:40.0];
- NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"flapfino\ntest" attributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]];
- NSRect viewBounds = [self bounds];
- NSRect stringBounds = [string boundingRectWithSize:viewBounds.size options:NSStringDrawingUsesLineFragmentOrigin];
- stringBounds.origin.x = NSWidth(viewBounds) / 2 - NSWidth(stringBounds) / 2;
- stringBounds.origin.y = NSHeight(viewBounds) / 2 - NSHeight(stringBounds) / 2;
- [[NSBezierPath bezierPathWithRect:stringBounds] stroke];
- [string drawInRect:stringBounds];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement