From b5e3d854acbc10265f243f6d06d2676738f14691 Mon Sep 17 00:00:00 2001 From: Alex Jarvis Date: Mon, 26 Oct 2015 15:36:04 +0000 Subject: [PATCH] Fix crash --- KILabel/Source/KILabel.m | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/KILabel/Source/KILabel.m b/KILabel/Source/KILabel.m index 37dbbff..6dd4b9e 100644 --- a/KILabel/Source/KILabel.m +++ b/KILabel/Source/KILabel.m @@ -353,12 +353,20 @@ - (NSDictionary *)attributesFromProperties paragraph.alignment = self.textAlignment; // Create the dictionary - NSDictionary *attributes = @{NSFontAttributeName : self.font, - NSForegroundColorAttributeName : color, - NSShadowAttributeName : shadow, - NSParagraphStyleAttributeName : paragraph, - }; - return attributes; + NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; + if (self.font != nil) { + [attributes setObject:self.font forKey:NSFontAttributeName]; + } + if (color != nil) { + [attributes setObject:color forKey:NSForegroundColorAttributeName]; + } + if (shadow != nil) { + [attributes setObject:shadow forKey:NSShadowAttributeName]; + } + if (paragraph != nil) { + [attributes setObject:paragraph forKey:NSParagraphStyleAttributeName]; + } + return [attributes copy]; } /**