Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 7053bf6

Browse files
committed
Fix CTText Deprecation Issue in iOS 13
1 parent 12baf65 commit 7053bf6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

CodeHub.iOS/DialogElements/NewsFeedElement.cs

100755100644
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using CoreGraphics;
4-
using System.Linq;
54
using Foundation;
65
using UIKit;
76
using CodeHub.iOS.TableViewCells;
@@ -24,8 +23,6 @@ public class NewsFeedElement : Element
2423

2524
public static UIColor LinkColor = Theme.CurrentTheme.MainTitleColor;
2625

27-
private UIImage LittleImage { get; set; }
28-
2926
public Action<NSUrl> WebLinkClicked;
3027

3128
public class TextBlock
@@ -74,15 +71,25 @@ public NewsFeedElement(string imageUrl, DateTimeOffset time, IEnumerable<TextBlo
7471
nint lengthCounter = 0;
7572
int i = 0;
7673

74+
CoreText.CTFont ctFont;
75+
76+
try
77+
{
78+
ctFont = new CoreText.CTFont(font.FamilyName, font.PointSize);
79+
}
80+
catch
81+
{
82+
ctFont = CGFont.CreateWithFontName(font.Name).ToCTFont(font.PointSize);
83+
}
84+
7785
foreach (var b in blocks)
7886
{
7987
UIColor color = null;
8088
if (b.Tapped != null)
8189
color = LinkColor;
8290

83-
color = color ?? primaryColor;
91+
color ??= primaryColor;
8492

85-
var ctFont = new CoreText.CTFont(font.Name, font.PointSize);
8693
var str = new NSAttributedString(b.Value, new CoreText.CTStringAttributes() { ForegroundColor = color.CGColor, Font = ctFont });
8794
attributedString.Append(str);
8895
var strLength = str.Length;

0 commit comments

Comments
 (0)