From 89f8993caebcceee143bb0dc07e68a74f7ddde36 Mon Sep 17 00:00:00 2001 From: Steven Deutsch Date: Fri, 10 Nov 2017 20:48:35 -0600 Subject: [PATCH] Add CHANGELOG entry and end image context --- CHANGELOG.md | 3 +++ Sources/Views/AvatarView.swift | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9386599b..a7c1cf91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa origin Y so that the `cellBottomLabel` is always under the `MessageContainerView`. [#326](https://github.com/MessageKit/MessageKit/pull/326) by [@SD10](https://github.com/sd10). +- Fixed pixelation of `AvatarView`'s placeholder text initials. +[#343](https://github.com/MessageKit/MessageKit/pull/343) by [@johnnyoin](https://github.com/johnnyoin). + ## [[Prerelease] 0.10.1](https://github.com/MessageKit/MessageKit/releases/tag/0.10.1) ### Fixed diff --git a/Sources/Views/AvatarView.swift b/Sources/Views/AvatarView.swift index 0fde7a29..ac705790 100644 --- a/Sources/Views/AvatarView.swift +++ b/Sources/Views/AvatarView.swift @@ -89,7 +89,8 @@ open class AvatarView: UIView { if width == 0 || height == 0 {return UIImage()} var font = placeholderFont - _ = UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, UIScreen.main.scale) + _ = UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, UIScreen.main.scale) + defer { UIGraphicsEndImageContext() } let context = UIGraphicsGetCurrentContext()! //// Text Drawing @@ -102,7 +103,7 @@ open class AvatarView: UIView { let textStyle = NSMutableParagraphStyle() textStyle.alignment = .center - let textFontAttributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: placeholderTextColor, NSAttributedStringKey.paragraphStyle: textStyle] + let textFontAttributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: placeholderTextColor, NSAttributedStringKey.paragraphStyle: textStyle] let textTextHeight: CGFloat = initals.boundingRect(with: CGSize(width: textRect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: textFontAttributes, context: nil).height context.saveGState()