├── samples └── SimpleChat │ ├── SimpleChat │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcons.appiconset │ │ │ └── Contents.json │ ├── packages.config │ ├── Main.cs │ ├── Entitlements.plist │ ├── AppDelegate.cs │ ├── ChatTableViewCell.designer.cs │ ├── ChatTableViewController.designer.cs │ ├── Info.plist │ ├── ChatTableViewController.cs │ ├── LaunchScreen.storyboard │ ├── AttributedStringUtil.cs │ ├── ChatTableViewCell.cs │ ├── Main.storyboard │ └── SimpleChat.csproj │ └── SimpleChat.sln ├── component ├── TTTAttributedLabel_128x128.png ├── TTTAttributedLabel_512x512.png ├── Details.md ├── License.md ├── component.yaml └── GettingStarted.md ├── extern ├── extras │ ├── StructsAndEnums.cs │ └── ApiDefinitions.cs └── Makefile ├── binding └── TTTAttributedLabel │ ├── TTTAttributedLabel.sln │ └── TTTAttributedLabel │ ├── TTTAttributedLabel.nuspec │ ├── Properties │ └── AssemblyInfo.cs │ └── TTTAttributedLabel.csproj ├── LICENSE ├── README.md └── .gitignore /samples/SimpleChat/SimpleChat/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /component/TTTAttributedLabel_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colbylwilliams/Xamarin.TTTAttributedLabel/HEAD/component/TTTAttributedLabel_128x128.png -------------------------------------------------------------------------------- /component/TTTAttributedLabel_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colbylwilliams/Xamarin.TTTAttributedLabel/HEAD/component/TTTAttributedLabel_512x512.png -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/Main.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace SimpleChat 4 | { 5 | public class Application 6 | { 7 | static void Main (string [] args) 8 | { 9 | UIApplication.Main (args, null, "AppDelegate"); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /component/Details.md: -------------------------------------------------------------------------------- 1 | # TTTAttributedLabel 2 | 3 | Xamarin.iOS binding for [TTTAttributedLabel][0], a drop-in replacement for UILabel that supports attributes, data detectors, links, and more. 4 | 5 | 6 | [0]:https://github.com/TTTAttributedLabel/TTTAttributedLabel -------------------------------------------------------------------------------- /extern/extras/StructsAndEnums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ObjCRuntime; 3 | 4 | namespace Xamarin.TTTAttributedLabel 5 | { 6 | [Native] 7 | public enum TTTAttributedLabelVerticalAlignment : ulong 8 | { 9 | Center = 0, 10 | Top = 1, 11 | Bottom = 2 12 | } 13 | } -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using UIKit; 3 | 4 | namespace SimpleChat 5 | { 6 | [Register ("AppDelegate")] 7 | public class AppDelegate : UIApplicationDelegate 8 | { 9 | public override UIWindow Window { get; set; } 10 | 11 | public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) => true; 12 | } 13 | } -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/ChatTableViewCell.designer.cs: -------------------------------------------------------------------------------- 1 | // WARNING 2 | // 3 | // This file has been generated automatically by Xamarin Studio to store outlets and 4 | // actions made in the UI designer. If it is removed, they will be lost. 5 | // Manual changes to this file may not be handled correctly. 6 | // 7 | using Foundation; 8 | using System.CodeDom.Compiler; 9 | 10 | namespace SimpleChat 11 | { 12 | [Register ("ChatTableViewCell")] 13 | partial class ChatTableViewCell 14 | { 15 | 16 | void ReleaseDesignerOutlets () 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/ChatTableViewController.designer.cs: -------------------------------------------------------------------------------- 1 | // WARNING 2 | // 3 | // This file has been generated automatically by Xamarin Studio to store outlets and 4 | // actions made in the UI designer. If it is removed, they will be lost. 5 | // Manual changes to this file may not be handled correctly. 6 | // 7 | using Foundation; 8 | using System.CodeDom.Compiler; 9 | 10 | namespace SimpleChat 11 | { 12 | [Register ("ChatTableViewController")] 13 | partial class ChatTableViewController 14 | { 15 | 16 | void ReleaseDesignerOutlets () 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /binding/TTTAttributedLabel/TTTAttributedLabel.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TTTAttributedLabel", "TTTAttributedLabel\TTTAttributedLabel.csproj", "{11775894-0AB1-47E9-929C-E9C1F07B0931}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {11775894-0AB1-47E9-929C-E9C1F07B0931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {11775894-0AB1-47E9-929C-E9C1F07B0931}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {11775894-0AB1-47E9-929C-E9C1F07B0931}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {11775894-0AB1-47E9-929C-E9C1F07B0931}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | EndGlobal 18 | -------------------------------------------------------------------------------- /binding/TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Xamarin.TTTAttributedLabel 5 | 2.0.0.2 6 | Xamarin.TTTAttributedLabel 7 | Colby Williams 8 | Colby Williams 9 | https://github.com/colbylwilliams/Xamarin.TTTAttributedLabel 10 | false 11 | Xamarin.iOS binding for TTTAttributedLabel 12 | The binding has been update to TTTAttributedLabel version 2.0.0 13 | Release Notes: https://github.com/TTTAttributedLabel/TTTAttributedLabel/releases/tag/2.0.0 14 | Copyright © 2016 Colby Williams 15 | Xamarin Xamarin.iOS iOS Unified TTTAttributedLabel 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Colby Williams 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /component/License.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Colby Williams 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /component/component.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: TTTAttributedLabel 4 | id: TTTAttributedLabel 5 | publisher: Colby Williams 6 | publisher-url: https://github.com/colbylwilliams 7 | summary: A drop-in replacement for UILabel that supports attributes, data detectors, links, and more 8 | version: 2.0.0.1 9 | src-url: https://github.com/colbylwilliams/Xamarin.TTTAttributedLabel 10 | 11 | details: Details.md 12 | getting-started: GettingStarted.md 13 | license: License.md 14 | 15 | is_shell: true 16 | no_build: true 17 | 18 | packages: 19 | ios-unified: 20 | - Xamarin.TTTAttributedLabel, Version=2.0.0.1 21 | # libraries: 22 | # ios-unified: 23 | # - 24 | local-nuget-repo: ../ 25 | 26 | icons: 27 | - TTTAttributedLabel_128x128.png 28 | - TTTAttributedLabel_512x512.png 29 | 30 | # samples: 31 | # iOS Sample: ../samples/SimpleChat/SimpleChat.sln 32 | 33 | samples: 34 | - name: Simple 35 | path: ../samples/SimpleChat/SimpleChat.sln 36 | # removeProjects: 37 | # - Square.SocketRocket 38 | installNuGets: 39 | - project: SimpleChat 40 | packages: 41 | - Xamarin.TTTAttributedLabel 42 | 43 | # screenshots: 44 | # - screenshots/screenshot1.png 45 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | SimpleChat 7 | CFBundleIdentifier 8 | com.xamarin.simplechat 9 | CFBundleShortVersionString 10 | 1.0 11 | CFBundleVersion 12 | 1.0 13 | LSRequiresIPhoneOS 14 | 15 | MinimumOSVersion 16 | 9.3 17 | UIDeviceFamily 18 | 19 | 1 20 | 2 21 | 22 | UILaunchStoryboardName 23 | LaunchScreen 24 | UIMainStoryboardFile 25 | Main 26 | UIRequiredDeviceCapabilities 27 | 28 | armv7 29 | 30 | UISupportedInterfaceOrientations 31 | 32 | UIInterfaceOrientationPortrait 33 | UIInterfaceOrientationLandscapeLeft 34 | UIInterfaceOrientationLandscapeRight 35 | 36 | XSAppIconAssets 37 | Assets.xcassets/AppIcons.appiconset 38 | 39 | 40 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleChat", "SimpleChat\SimpleChat.csproj", "{E73BA4F1-418E-4662-93C7-3B989DD5F3D0}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 9 | Release|iPhone = Release|iPhone 10 | Release|iPhoneSimulator = Release|iPhoneSimulator 11 | Debug|iPhone = Debug|iPhone 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator 15 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator 16 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Release|iPhone.ActiveCfg = Release|iPhone 17 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Release|iPhone.Build.0 = Release|iPhone 18 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator 19 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator 20 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Debug|iPhone.ActiveCfg = Debug|iPhone 21 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0}.Debug|iPhone.Build.0 = Debug|iPhone 22 | EndGlobalSection 23 | EndGlobal 24 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/ChatTableViewController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using Foundation; 5 | using UIKit; 6 | 7 | namespace SimpleChat 8 | { 9 | public partial class ChatTableViewController : UITableViewController 10 | { 11 | readonly List Messages = new List (); 12 | 13 | 14 | public ChatTableViewController (IntPtr handle) : base (handle) { } 15 | 16 | 17 | public override void ViewDidLoad () 18 | { 19 | base.ViewDidLoad (); 20 | 21 | var messageString = "Lorem ipsum dolor sit amet"; 22 | 23 | var wordArray = messageString.Split (' '); 24 | 25 | for (int i = 0; i < 20; i++) { 26 | for (int ii = 0; ii < wordArray.Length; ii++) 27 | Messages.Add (messageString.GetMessageAttributedString (wordArray [ii])); 28 | 29 | Messages.Add ("Xamarin.TTTAttributedLabel".GetMessageAttributedString ("Xamarin.TTTAttributedLabel", true)); 30 | } 31 | } 32 | 33 | 34 | public override nint NumberOfSections (UITableView tableView) => 1; 35 | 36 | 37 | public override nint RowsInSection (UITableView tableView, nint section) => Messages.Count; 38 | 39 | 40 | public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) 41 | { 42 | var cell = TableView.DequeueReusableCell (ChatTableViewCell.ReuseId, indexPath) as ChatTableViewCell; 43 | 44 | var message = Messages [indexPath.Row]; 45 | 46 | cell.SetMessage (message); 47 | 48 | return cell; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /binding/TTTAttributedLabel/TTTAttributedLabel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | using Foundation; 5 | 6 | // This attribute allows you to mark your assemblies as “safe to link”. 7 | // When the attribute is present, the linker—if enabled—will process the assembly 8 | // even if you’re using the “Link SDK assemblies only” option, which is the default for device builds. 9 | 10 | [assembly: LinkerSafe] 11 | 12 | // Information about this assembly is defined by the following attributes. 13 | // Change them to the values specific to your project. 14 | 15 | [assembly: AssemblyTitle ("Xamarin.TTTAttributedLabel")] 16 | [assembly: AssemblyDescription ("Xamarin.iOS binding for TTTAttributedLabel")] 17 | [assembly: AssemblyConfiguration ("")] 18 | [assembly: AssemblyCompany ("Colby Williams")] 19 | [assembly: AssemblyProduct ("")] 20 | [assembly: AssemblyCopyright ("Copyright © 2016 Colby Williams")] 21 | [assembly: AssemblyTrademark ("")] 22 | [assembly: AssemblyCulture ("")] 23 | 24 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 25 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 26 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 27 | 28 | [assembly: AssemblyVersion ("2.0.0.1")] 29 | 30 | // The following attributes are used to specify the signing key for the assembly, 31 | // if desired. See the Mono documentation for more information about signing. 32 | 33 | //[assembly: AssemblyDelaySign(false)] 34 | //[assembly: AssemblyKeyFile("")] 35 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/AttributedStringUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Foundation; 4 | using UIKit; 5 | 6 | namespace SimpleChat 7 | { 8 | public static class AttributedStringUtil 9 | { 10 | public static UIFont DefaultFont = UIFont.SystemFontOfSize (16); 11 | 12 | 13 | public static UIColor MessageColor = UIColor.FromRGBA (44f / 255f, 45f / 255f, 48f / 255f, 255f / 255f); 14 | 15 | public static UIColor MessageLinkColor = UIColor.FromRGBA (43f / 255f, 128f / 255f, 185f / 255f, 255f / 255f); 16 | 17 | 18 | public static NSMutableParagraphStyle MessageParagraphStyle = new NSMutableParagraphStyle { 19 | LineBreakMode = UILineBreakMode.WordWrap, 20 | Alignment = UITextAlignment.Left 21 | }; 22 | 23 | 24 | public static UIStringAttributes MessageStringAttributes = new UIStringAttributes { 25 | Font = DefaultFont, 26 | ParagraphStyle = MessageParagraphStyle, 27 | ForegroundColor = MessageColor 28 | }; 29 | 30 | 31 | public static UIStringAttributes BoldStringAttributes = new UIStringAttributes { 32 | Font = UIFont.BoldSystemFontOfSize (16), 33 | ParagraphStyle = MessageParagraphStyle, 34 | ForegroundColor = MessageColor 35 | }; 36 | 37 | 38 | public static UIStringAttributes LinkStringAttributes = new UIStringAttributes { 39 | Font = DefaultFont, 40 | UnderlineStyle = NSUnderlineStyle.Single, 41 | ParagraphStyle = MessageParagraphStyle, 42 | ForegroundColor = MessageLinkColor 43 | }; 44 | 45 | 46 | static readonly NSUrl link = NSUrl.FromString ("https://github.com/colbylwilliams/Xamarin.TTTAttributedLabel"); 47 | 48 | 49 | public static NSMutableAttributedString GetMessageAttributedString (this string message, string boldWord, bool mockLink = false) 50 | { 51 | var attrString = new NSMutableAttributedString (message); 52 | 53 | attrString.AddAttributes (MessageStringAttributes, new NSRange (0, message.Length)); 54 | 55 | var range = new NSRange (message.IndexOf (boldWord, StringComparison.Ordinal), boldWord.Length); 56 | 57 | if (mockLink) { 58 | 59 | attrString.AddAttribute (UIStringAttributeKey.Link, link, range); 60 | 61 | attrString.AddAttributes (LinkStringAttributes, range); 62 | 63 | } else { 64 | 65 | attrString.AddAttributes (BoldStringAttributes, range); 66 | } 67 | 68 | return attrString; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /component/GettingStarted.md: -------------------------------------------------------------------------------- 1 | # Getting Started with TTTAttributedLabel 2 | 3 | `TTTAttributedLabel` can display both plain and attributed text: just pass an `NSString` or `NSAttributedString` to the `SetText`. Never assign to the `AttributedText` property. 4 | 5 | ``` C# 6 | // NSAttributedString 7 | 8 | var attributedLabel = new TTTAttributedLabel (); 9 | 10 | var attString = new NSAttributedString ("Tom Bombadil", new UIStringAttributes { 11 | ForegroundColor = UIColor.Red, 12 | Font = UIFont.BoldSystemFontOfSize (16), 13 | KerningAdjustment = null, 14 | BackgroundColor = UIColor.Green 15 | }); 16 | 17 | // The attributed string is directly set, without inheriting any other text 18 | // properties of the label. 19 | attributedLabel.SetText(attString); 20 | ``` 21 | 22 | ``` C# 23 | // NSString 24 | 25 | TTTAttributedLabel label = new TTTAttributedLabel (); 26 | label.Font = UIFont.SystemFontOfSize (14); 27 | label.TextColor = UIColor.DarkGray; 28 | label.LineBreakMode = UILineBreakMode.WordWrap; 29 | label.Lines = 0; 30 | 31 | // If you're using a simple `NSString` for your text, 32 | // assign to the `text` property last so it can inherit other label properties. 33 | NSString text = new NSString ("Lorem ipsum dolor sit amet"); 34 | 35 | label.SetText (text, (NSMutableAttributedString mutableAttributedString) => { 36 | 37 | var boldText = "ipsum dolor"; 38 | var strikeText = "sit amet"; 39 | 40 | var boldRange = new NSRange (mutableAttributedString.ToString ().IndexOf (boldText, StringComparison.OrdinalIgnoreCase), boldText.Length); 41 | var strikeRange = new NSRange (mutableAttributedString.ToString ().IndexOf (strikeText, StringComparison.OrdinalIgnoreCase), strikeText.Length); 42 | 43 | var boldSystemFont = UIFont.BoldSystemFontOfSize (14); 44 | 45 | mutableAttributedString.AddAttribute (UIStringAttributeKey.Font, boldSystemFont, boldRange); 46 | mutableAttributedString.AddAttribute (TTTAttributeNames.StrikeOut, NSObject.FromObject (true), strikeRange); 47 | 48 | return mutableAttributedString; 49 | }); 50 | ``` 51 | First, we create and configure the label, the same way you would instantiate `UILabel`. Any text properties that are set on the label are inherited as the base attributes when using the `SetText` method. In this example, the substring "ipsum dolar", would appear in bold, such that the label would read "Lorem **ipsum dolar** sit amet", in size 14 Helvetica, with a dark gray color. 52 | -------------------------------------------------------------------------------- /binding/TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {11775894-0AB1-47E9-929C-E9C1F07B0931} 7 | {8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | Xamarin.TTTAttributedLabel 10 | Xamarin.TTTAttributedLabel 11 | Resources 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | false 22 | true 23 | 24 | 25 | true 26 | bin\Release 27 | prompt 28 | 4 29 | false 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Framework 42 | False 43 | 44 | 45 | 46 | 47 | ApiDefinitions.cs 48 | 49 | 50 | 51 | 52 | StructsAndEnums.cs 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/ChatTableViewCell.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Foundation; 4 | using UIKit; 5 | 6 | using Xamarin.TTTAttributedLabel; 7 | 8 | namespace SimpleChat 9 | { 10 | public partial class ChatTableViewCell : UITableViewCell, ITTTAttributedLabelDelegate 11 | { 12 | public static readonly NSString ReuseId = new NSString ("ChatTableViewCell"); 13 | 14 | 15 | TTTAttributedLabel _bodyLabel; 16 | public TTTAttributedLabel BodyLabel { 17 | get { 18 | if (_bodyLabel == null) { 19 | _bodyLabel = new TTTAttributedLabel { 20 | TranslatesAutoresizingMaskIntoConstraints = false, 21 | BackgroundColor = UIColor.White, 22 | UserInteractionEnabled = true, 23 | Lines = 0, 24 | TextColor = AttributedStringUtil.MessageColor, 25 | Font = AttributedStringUtil.DefaultFont, 26 | LinkAttributes = AttributedStringUtil.LinkStringAttributes.Dictionary, 27 | EnabledTextCheckingTypes = NSTextCheckingType.Link, 28 | WeakDelegate = this 29 | }; 30 | } 31 | return _bodyLabel; 32 | } 33 | } 34 | 35 | 36 | public ChatTableViewCell (IntPtr handle) : base (handle) 37 | { 38 | BackgroundColor = UIColor.White; 39 | SelectionStyle = UITableViewCellSelectionStyle.None; 40 | 41 | configureSubviews (); 42 | configureConstraints (); 43 | } 44 | 45 | 46 | public override void PrepareForReuse () 47 | { 48 | base.PrepareForReuse (); 49 | 50 | SelectionStyle = UITableViewCellSelectionStyle.None; 51 | } 52 | 53 | 54 | void configureSubviews () => ContentView.AddSubview (BodyLabel); 55 | 56 | 57 | void configureConstraints () 58 | { 59 | var views = new NSDictionary ( 60 | new NSString (@"bodyLabel"), BodyLabel 61 | ); 62 | 63 | var metrics = new NSDictionary ( 64 | new NSString (@"tumbSize"), NSNumber.FromNFloat (30), 65 | new NSString (@"right"), NSNumber.FromNFloat (10) 66 | ); 67 | 68 | ContentView.AddConstraints (NSLayoutConstraint.FromVisualFormat (@"H:|-tumbSize-[bodyLabel(>=0)]-right-|", 0, metrics, views)); 69 | ContentView.AddConstraints (NSLayoutConstraint.FromVisualFormat (@"V:|[bodyLabel]|", 0, metrics, views)); 70 | } 71 | 72 | 73 | public virtual void SetMessage (NSAttributedString message) => BodyLabel.SetText (message); 74 | 75 | 76 | [Export ("attributedLabel:didSelectLinkWithURL:")] 77 | public void DidSelectLinkWithURL (TTTAttributedLabel label, NSUrl url) 78 | { 79 | UIApplication.SharedApplication.OpenUrl (url); 80 | 81 | System.Diagnostics.Debug.WriteLine ($"DidSelectLinkWithURL Label = {label}, Url = {url})"); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /extern/Makefile: -------------------------------------------------------------------------------- 1 | IOS_RELEASE=2.0.0 2 | 3 | CONFIGURATION=Release 4 | 5 | XCODEBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild 6 | TARGET=TTTAttributedLabel 7 | PROJECT=TTTAttributedLabel.xcodeproj 8 | FRAMEWORK=TTTAttributedLabel.framework 9 | 10 | all : clean ../binding/TTTAttributedLabel/TTTAttributedLabel/bin/$(CONFIGURATION)/Xamarin.TTTAttributedLabel.dll 11 | 12 | TTTAttributedLabel/README.md : 13 | git clone git@github.com:TTTAttributedLabel/TTTAttributedLabel.git 14 | cd TTTAttributedLabel && git checkout $(IOS_RELEASE) 15 | 16 | $(CONFIGURATION)-iphoneos/$(FRAMEWORK) : TTTAttributedLabel/README.md 17 | cd TTTAttributedLabel/Carthage && $(XCODEBUILD) OTHER_CFLAGS="-fembed-bitcode" -project $(PROJECT) -target $(TARGET) -sdk iphoneos -configuration $(CONFIGURATION) clean build 18 | -mv TTTAttributedLabel/Carthage/build/$(CONFIGURATION)-iphoneos ./ 19 | 20 | $(CONFIGURATION)-iphonesimulator/$(FRAMEWORK) : $(CONFIGURATION)-iphoneos/$(FRAMEWORK) 21 | cd TTTAttributedLabel/Carthage && $(XCODEBUILD) OTHER_CFLAGS="-fembed-bitcode" -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration $(CONFIGURATION) clean build 22 | -mv TTTAttributedLabel/Carthage/build/$(CONFIGURATION)-iphonesimulator ./ 23 | 24 | $(CONFIGURATION)-iphoneuniversal/$(FRAMEWORK) : $(CONFIGURATION)-iphonesimulator/$(FRAMEWORK) 25 | mkdir -p $(CONFIGURATION)-iphoneuniversal/$(FRAMEWORK) 26 | cp -r $(CONFIGURATION)-iphoneos/$(FRAMEWORK)/. $(CONFIGURATION)-iphoneuniversal/$(FRAMEWORK) 27 | lipo $(CONFIGURATION)-iphonesimulator/$(FRAMEWORK)/$(TARGET) $(CONFIGURATION)-iphoneos/$(FRAMEWORK)/$(TARGET) -create -output $(CONFIGURATION)-iphoneuniversal/$(FRAMEWORK)/$(TARGET) 28 | 29 | $(CONFIGURATION)-binding/ApiDefinitions.cs : $(CONFIGURATION)-iphoneuniversal/$(FRAMEWORK) 30 | mkdir -p $(CONFIGURATION)-binding 31 | cp extras/ApiDefinitions.cs $(CONFIGURATION)-binding 32 | cp extras/StructsAndEnums.cs $(CONFIGURATION)-binding 33 | # sharpie bind \ 34 | # -n Xamarin.TTTAttributedLabel \ 35 | # -o $(CONFIGURATION)-binding \ 36 | # -sdk iphoneos \ 37 | # TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.h 38 | 39 | ../binding/TTTAttributedLabel/TTTAttributedLabel/bin/$(CONFIGURATION)/Xamarin.TTTAttributedLabel.dll : $(CONFIGURATION)-binding/ApiDefinitions.cs 40 | cd ../binding/TTTAttributedLabel/TTTAttributedLabel && XBuild /p:Configuration=$(CONFIGURATION) 41 | cd ../binding/TTTAttributedLabel/TTTAttributedLabel && nuget pack TTTAttributedLabel.nuspec 42 | 43 | clean : 44 | # rm -rf TTTAttributedLabel 45 | rm -rf $(CONFIGURATION)-binding 46 | rm -rf $(CONFIGURATION)-iphoneos 47 | rm -rf $(CONFIGURATION)-iphonesimulator 48 | rm -rf $(CONFIGURATION)-iphoneuniversal -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/Assets.xcassets/AppIcons.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "iphone", 5 | "size": "29x29", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "iphone", 10 | "size": "29x29", 11 | "scale": "2x" 12 | }, 13 | { 14 | "idiom": "iphone", 15 | "size": "29x29", 16 | "scale": "3x" 17 | }, 18 | { 19 | "idiom": "iphone", 20 | "size": "40x40", 21 | "scale": "2x" 22 | }, 23 | { 24 | "idiom": "iphone", 25 | "size": "40x40", 26 | "scale": "3x" 27 | }, 28 | { 29 | "idiom": "iphone", 30 | "size": "57x57", 31 | "scale": "1x" 32 | }, 33 | { 34 | "idiom": "iphone", 35 | "size": "57x57", 36 | "scale": "2x" 37 | }, 38 | { 39 | "idiom": "iphone", 40 | "size": "60x60", 41 | "scale": "2x" 42 | }, 43 | { 44 | "idiom": "iphone", 45 | "size": "60x60", 46 | "scale": "3x" 47 | }, 48 | { 49 | "idiom": "ipad", 50 | "size": "29x29", 51 | "scale": "1x" 52 | }, 53 | { 54 | "idiom": "ipad", 55 | "size": "29x29", 56 | "scale": "2x" 57 | }, 58 | { 59 | "idiom": "ipad", 60 | "size": "40x40", 61 | "scale": "1x" 62 | }, 63 | { 64 | "idiom": "ipad", 65 | "size": "40x40", 66 | "scale": "2x" 67 | }, 68 | { 69 | "idiom": "ipad", 70 | "size": "50x50", 71 | "scale": "1x" 72 | }, 73 | { 74 | "idiom": "ipad", 75 | "size": "50x50", 76 | "scale": "2x" 77 | }, 78 | { 79 | "idiom": "ipad", 80 | "size": "72x72", 81 | "scale": "1x" 82 | }, 83 | { 84 | "idiom": "ipad", 85 | "size": "72x72", 86 | "scale": "2x" 87 | }, 88 | { 89 | "idiom": "ipad", 90 | "size": "76x76", 91 | "scale": "1x" 92 | }, 93 | { 94 | "idiom": "ipad", 95 | "size": "76x76", 96 | "scale": "2x" 97 | }, 98 | { 99 | "size": "24x24", 100 | "idiom": "watch", 101 | "scale": "2x", 102 | "role": "notificationCenter", 103 | "subtype": "38mm" 104 | }, 105 | { 106 | "size": "27.5x27.5", 107 | "idiom": "watch", 108 | "scale": "2x", 109 | "role": "notificationCenter", 110 | "subtype": "42mm" 111 | }, 112 | { 113 | "size": "29x29", 114 | "idiom": "watch", 115 | "role": "companionSettings", 116 | "scale": "2x" 117 | }, 118 | { 119 | "size": "29x29", 120 | "idiom": "watch", 121 | "role": "companionSettings", 122 | "scale": "3x" 123 | }, 124 | { 125 | "size": "40x40", 126 | "idiom": "watch", 127 | "scale": "2x", 128 | "role": "appLauncher", 129 | "subtype": "38mm" 130 | }, 131 | { 132 | "size": "44x44", 133 | "idiom": "watch", 134 | "scale": "2x", 135 | "role": "longLook", 136 | "subtype": "42mm" 137 | }, 138 | { 139 | "size": "86x86", 140 | "idiom": "watch", 141 | "scale": "2x", 142 | "role": "quickLook", 143 | "subtype": "38mm" 144 | }, 145 | { 146 | "size": "98x98", 147 | "idiom": "watch", 148 | "scale": "2x", 149 | "role": "quickLook", 150 | "subtype": "42mm" 151 | } 152 | ], 153 | "info": { 154 | "version": 1, 155 | "author": "xcode" 156 | } 157 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Xamarin.TTTAttributedLabel ![NuGet](https://img.shields.io/nuget/v/Xamarin.TTTAttributedLabel.svg?label=NuGet) 2 | 3 | A Xamarin.iOS binding for [TTTAttributedLabel][0] 4 | 5 | 6 | ## Installation 7 | Either add the [NuGet package][2] or [Component][3] to your Xamarin.iOS project (recommended), or clone this repo, build using the steps below, and reference the TTTAttributedLabel project from your Xamarin.iOS project. 8 | 9 | 10 | ## Usage 11 | Examples ported from [TTTAttributedLabel Usage][1] section. 12 | 13 | `TTTAttributedLabel` can display both plain and attributed text: just pass an `NSString` or `NSAttributedString` to the `SetText`. Never assign to the `AttributedText` property. 14 | 15 | ``` C# 16 | // NSAttributedString 17 | 18 | var attributedLabel = new TTTAttributedLabel (); 19 | 20 | var attString = new NSAttributedString ("Tom Bombadil", new UIStringAttributes { 21 | ForegroundColor = UIColor.Red, 22 | Font = UIFont.BoldSystemFontOfSize (16), 23 | KerningAdjustment = null, 24 | BackgroundColor = UIColor.Green 25 | }); 26 | 27 | // The attributed string is directly set, without inheriting any other text 28 | // properties of the label. 29 | attributedLabel.SetText(attString); 30 | ``` 31 | 32 | ``` C# 33 | // NSString 34 | 35 | TTTAttributedLabel label = new TTTAttributedLabel (); 36 | label.Font = UIFont.SystemFontOfSize (14); 37 | label.TextColor = UIColor.DarkGray; 38 | label.LineBreakMode = UILineBreakMode.WordWrap; 39 | label.Lines = 0; 40 | 41 | // If you're using a simple `NSString` for your text, 42 | // assign to the `text` property last so it can inherit other label properties. 43 | NSString text = new NSString ("Lorem ipsum dolor sit amet"); 44 | 45 | label.SetText (text, (NSMutableAttributedString mutableAttributedString) => { 46 | 47 | var boldText = "ipsum dolor"; 48 | var strikeText = "sit amet"; 49 | 50 | var boldRange = new NSRange (mutableAttributedString.ToString ().IndexOf (boldText, StringComparison.OrdinalIgnoreCase), boldText.Length); 51 | var strikeRange = new NSRange (mutableAttributedString.ToString ().IndexOf (strikeText, StringComparison.OrdinalIgnoreCase), strikeText.Length); 52 | 53 | var boldSystemFont = UIFont.BoldSystemFontOfSize (14); 54 | 55 | mutableAttributedString.AddAttribute (UIStringAttributeKey.Font, boldSystemFont, boldRange); 56 | mutableAttributedString.AddAttribute (TTTAttributeNames.StrikeOut, NSObject.FromObject (true), strikeRange); 57 | 58 | return mutableAttributedString; 59 | }); 60 | ``` 61 | First, we create and configure the label, the same way you would instantiate `UILabel`. Any text properties that are set on the label are inherited as the base attributes when using the `SetText` method. In this example, the substring "ipsum dolar", would appear in bold, such that the label would read "Lorem **ipsum dolar** sit amet", in size 14 Helvetica, with a dark gray color. 62 | 63 | 64 | ## Building 65 | 66 | To build, run `make` in the `extern` directory. Then open `bindings/TTTAttributedLabel/TTTAttributedLabel.sln` in Xamarin Studio and build. 67 | 68 | ### Requirements 69 | 70 | * Xamarin Studio 6.0+ (`XBuild`) 71 | * `xcodebuild` 72 | 73 | 74 | ## Todo 75 | 76 | * Sample project 77 | * Xamarin Component 78 | 79 | 80 | ## License 81 | 82 | `Xamarin.TTTAttributedLabel` is available under the MIT license. See the LICENSE file for more info. 83 | 84 | [0]:https://github.com/TTTAttributedLabel/TTTAttributedLabel 85 | [1]:https://github.com/TTTAttributedLabel/TTTAttributedLabel#usage 86 | [2]:https://www.nuget.org/packages/Xamarin.TTTAttributedLabel 87 | [3]:https://components.xamarin.com/view/tttattributedlabel -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | *.userprefs 9 | 10 | # Xamarin.Android 11 | Resource.designer.cs 12 | Resources.designer.cs 13 | 14 | # Xamarin Components 15 | Components/ 16 | 17 | # Build results 18 | [Dd]ebug/ 19 | [Dd]ebugPublic/ 20 | [Rr]elease/ 21 | x64/ 22 | build/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | 27 | # MSTest test Results 28 | [Tt]est[Rr]esult*/ 29 | [Bb]uild[Ll]og.* 30 | 31 | #NUNIT 32 | *.VisualState.xml 33 | TestResult.xml 34 | 35 | # Build Results of an ATL Project 36 | [Dd]ebugPS/ 37 | [Rr]eleasePS/ 38 | dlldata.c 39 | 40 | *_i.c 41 | *_p.c 42 | *_i.h 43 | *.ilk 44 | *.meta 45 | *.obj 46 | *.pch 47 | *.pdb 48 | *.pgc 49 | *.pgd 50 | *.rsp 51 | *.sbr 52 | *.tlb 53 | *.tli 54 | *.tlh 55 | *.tmp 56 | *.tmp_proj 57 | *.log 58 | *.vspscc 59 | *.vssscc 60 | .builds 61 | *.pidb 62 | *.svclog 63 | *.scc 64 | 65 | # Chutzpah Test files 66 | _Chutzpah* 67 | 68 | # Visual C++ cache files 69 | ipch/ 70 | *.aps 71 | *.ncb 72 | *.opensdf 73 | *.sdf 74 | *.cachefile 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | *.vspx 80 | 81 | # TFS 2012 Local Workspace 82 | $tf/ 83 | 84 | # Guidance Automation Toolkit 85 | *.gpState 86 | 87 | # ReSharper is a .NET coding add-in 88 | _ReSharper*/ 89 | *.[Rr]e[Ss]harper 90 | *.DotSettings.user 91 | 92 | # JustCode is a .NET coding addin-in 93 | .JustCode 94 | 95 | # TeamCity is a build add-in 96 | _TeamCity* 97 | 98 | 99 | # NCrunch 100 | *.ncrunch* 101 | _NCrunch_* 102 | .*crunch*.local.xml 103 | 104 | # MightyMoose 105 | *.mm.* 106 | AutoTest.Net/ 107 | 108 | # Web workbench (sass) 109 | .sass-cache/ 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.[Pp]ublish.xml 129 | *.azurePubxml 130 | 131 | # NuGet Packages Directory 132 | packages/ 133 | ## TODO: If the tool you use requires repositories.config uncomment the next line 134 | #!packages/repositories.config 135 | 136 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 137 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) 138 | !packages/build/ 139 | 140 | # Windows Azure Build Output 141 | csx/ 142 | *.build.csdef 143 | 144 | # Windows Store app package directory 145 | AppPackages/ 146 | 147 | # Others 148 | sql/ 149 | *.Cache 150 | ClientBin/ 151 | [Ss]tyle[Cc]op.* 152 | ~$* 153 | *~ 154 | *.dbmdl 155 | *.dbproj.schemaview 156 | *.pfx 157 | *.publishsettings 158 | node_modules/ 159 | 160 | # RIA/Silverlight projects 161 | Generated_Code/ 162 | 163 | # Backup & report files from converting an old project file to a newer 164 | # Visual Studio version. Backup files are not needed, because we have git ;-) 165 | _UpgradeReport_Files/ 166 | Backup*/ 167 | UpgradeLog*.XML 168 | UpgradeLog*.htm 169 | 170 | # SQL Server files 171 | *.mdf 172 | *.ldf 173 | 174 | # Business Intelligence projects 175 | *.rdl.data 176 | *.bim.layout 177 | *.bim_*.settings 178 | 179 | # Microsoft Fakes 180 | FakesAssemblies/ 181 | 182 | # Xamarin 183 | #Autosave files 184 | *~ 185 | 186 | #build 187 | [Oo]bj/ 188 | [Bb]in/ 189 | packages/ 190 | TestResults/ 191 | 192 | # globs 193 | Makefile.in 194 | *.DS_Store 195 | *.sln.cache 196 | *.cache 197 | *.pidb 198 | *.userprefs 199 | *.usertasks 200 | config.log 201 | config.make 202 | config.status 203 | aclocal.m4 204 | install-sh 205 | autom4te.cache/ 206 | *.tar.gz 207 | tarballs/ 208 | test-results/ 209 | Thumbs.db 210 | 211 | #Mac bundle stuff 212 | *.dmg 213 | *.app 214 | 215 | #bitrise 216 | .bitrise* 217 | 218 | #extern 219 | extern/Release-binding 220 | extern/Release-iphoneos 221 | extern/Release-iphonesimulator 222 | extern/Release-iphoneuniversal 223 | extern/TTTAttributedLabel 224 | extern/Xamarin.TTTAttributedLabel.* 225 | 226 | old 227 | old/*.cs 228 | local/TTTAttributedLabel.psd 229 | 230 | *.xam 231 | -------------------------------------------------------------------------------- /samples/SimpleChat/SimpleChat/SimpleChat.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | iPhoneSimulator 6 | {E73BA4F1-418E-4662-93C7-3B989DD5F3D0} 7 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Exe 9 | SimpleChat 10 | SimpleChat 11 | Resources 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\iPhoneSimulator\Debug 18 | DEBUG;ENABLE_TEST_CLOUD; 19 | prompt 20 | 4 21 | false 22 | iPhone Developer 23 | true 24 | true 25 | true 26 | true 27 | true 28 | None 29 | i386 30 | x86 31 | 32 | 33 | true 34 | bin\iPhone\Release 35 | prompt 36 | 4 37 | false 38 | iPhone Developer 39 | true 40 | true 41 | true 42 | Entitlements.plist 43 | ARMv7, ARM64 44 | x86 45 | 46 | 47 | true 48 | bin\iPhoneSimulator\Release 49 | prompt 50 | 4 51 | false 52 | iPhone Developer 53 | true 54 | true 55 | None 56 | i386 57 | x86 58 | 59 | 60 | true 61 | full 62 | false 63 | bin\iPhone\Debug 64 | DEBUG;ENABLE_TEST_CLOUD; 65 | prompt 66 | 4 67 | false 68 | iPhone Developer 69 | true 70 | true 71 | true 72 | true 73 | true 74 | true 75 | true 76 | Entitlements.plist 77 | ARMv7, ARM64 78 | x86 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | ..\packages\Xamarin.TTTAttributedLabel.2.0.0\lib\Xamarin.iOS\Xamarin.TTTAttributedLabel.dll 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | ChatTableViewController.cs 111 | 112 | 113 | 114 | ChatTableViewCell.cs 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /extern/extras/ApiDefinitions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CoreGraphics; 3 | using Foundation; 4 | using ObjCRuntime; 5 | using UIKit; 6 | 7 | namespace Xamarin.TTTAttributedLabel 8 | { 9 | [Static] 10 | //[Verify (ConstantsInterfaceAssociation)] 11 | partial interface Constants 12 | { 13 | //extern double TTTAttributedLabelVersionNumber; 14 | [Field ("TTTAttributedLabelVersionNumber", "__Internal")] 15 | double TTTAttributedLabelVersionNumber { get; } 16 | 17 | // extern const unsigned char [] TTTAttributedLabelVersionString; 18 | [Field ("TTTAttributedLabelVersionString", "__Internal")] 19 | NSString TTTAttributedLabelVersionString { get; } 20 | } 21 | 22 | [Static] 23 | //[Verify (ConstantsInterfaceAssociation)] 24 | partial interface TTTAttributeNames 25 | { 26 | // extern NSString *const kTTTStrikeOutAttributeName; 27 | [Field ("kTTTStrikeOutAttributeName", "__Internal")] 28 | NSString kTTTStrikeOutAttributeName { get; } 29 | 30 | // extern NSString *const kTTTBackgroundFillColorAttributeName; 31 | [Field ("kTTTBackgroundFillColorAttributeName", "__Internal")] 32 | NSString kTTTBackgroundFillColorAttributeName { get; } 33 | 34 | // extern NSString *const kTTTBackgroundFillPaddingAttributeName; 35 | [Field ("kTTTBackgroundFillPaddingAttributeName", "__Internal")] 36 | NSString kTTTBackgroundFillPaddingAttributeName { get; } 37 | 38 | // extern NSString *const kTTTBackgroundStrokeColorAttributeName; 39 | [Field ("kTTTBackgroundStrokeColorAttributeName", "__Internal")] 40 | NSString kTTTBackgroundStrokeColorAttributeName { get; } 41 | 42 | // extern NSString *const kTTTBackgroundLineWidthAttributeName; 43 | [Field ("kTTTBackgroundLineWidthAttributeName", "__Internal")] 44 | NSString kTTTBackgroundLineWidthAttributeName { get; } 45 | 46 | // extern NSString *const kTTTBackgroundCornerRadiusAttributeName; 47 | [Field ("kTTTBackgroundCornerRadiusAttributeName", "__Internal")] 48 | NSString kTTTBackgroundCornerRadiusAttributeName { get; } 49 | } 50 | 51 | // @protocol TTTAttributedLabel 52 | //[Protocol, Model] 53 | //[BaseType (typeof (NSObject))] 54 | //interface ITTTAttributedLabel 55 | //{ 56 | // // @required @property (copy, nonatomic) id text; 57 | // [Export ("text", ArgumentSemantic.Copy)] 58 | // NSObject Text { get; set; } 59 | //} 60 | 61 | // @interface TTTAttributedLabel : UILabel 62 | [BaseType (typeof (UILabel))] 63 | //[DisableDefaultCtor] 64 | interface TTTAttributedLabel : /*ITTTAttributedLabel, */IUIGestureRecognizerDelegate 65 | { 66 | [Wrap ("WeakDelegate")] 67 | TTTAttributedLabelDelegate Delegate { get; set; } 68 | 69 | // @property (nonatomic, unsafe_unretained) id delegate __attribute__((iboutlet)); 70 | [NullAllowed, Export ("delegate", ArgumentSemantic.Assign)] 71 | NSObject WeakDelegate { get; set; } 72 | 73 | // @property (assign, nonatomic) NSTextCheckingTypes enabledTextCheckingTypes; 74 | [Export ("enabledTextCheckingTypes")] 75 | NSTextCheckingType EnabledTextCheckingTypes { get; set; } 76 | 77 | // @property (readonly, nonatomic, strong) NSArray * links; 78 | [Export ("links", ArgumentSemantic.Strong)] 79 | //[Verify (StronglyTypedNSArray)] 80 | TTTAttributedLabelLink [] Links { get; } 81 | 82 | // @property (nonatomic, strong) NSDictionary * linkAttributes; 83 | [Export ("linkAttributes", ArgumentSemantic.Strong)] 84 | NSDictionary LinkAttributes { get; set; } 85 | 86 | // @property (nonatomic, strong) NSDictionary * activeLinkAttributes; 87 | [Export ("activeLinkAttributes", ArgumentSemantic.Strong)] 88 | NSDictionary ActiveLinkAttributes { get; set; } 89 | 90 | // @property (nonatomic, strong) NSDictionary * inactiveLinkAttributes; 91 | [Export ("inactiveLinkAttributes", ArgumentSemantic.Strong)] 92 | NSDictionary InactiveLinkAttributes { get; set; } 93 | 94 | // @property (assign, nonatomic) UIEdgeInsets linkBackgroundEdgeInset; 95 | [Export ("linkBackgroundEdgeInset", ArgumentSemantic.Assign)] 96 | UIEdgeInsets LinkBackgroundEdgeInset { get; set; } 97 | 98 | // @property (assign, nonatomic) BOOL extendsLinkTouchArea; 99 | [Export ("extendsLinkTouchArea")] 100 | bool ExtendsLinkTouchArea { get; set; } 101 | 102 | // @property (assign, nonatomic) CGFloat shadowRadius; 103 | [Export ("shadowRadius")] 104 | nfloat ShadowRadius { get; set; } 105 | 106 | // @property (assign, nonatomic) CGFloat highlightedShadowRadius; 107 | [Export ("highlightedShadowRadius")] 108 | nfloat HighlightedShadowRadius { get; set; } 109 | 110 | // @property (assign, nonatomic) CGSize highlightedShadowOffset; 111 | [Export ("highlightedShadowOffset", ArgumentSemantic.Assign)] 112 | CGSize HighlightedShadowOffset { get; set; } 113 | 114 | // @property (nonatomic, strong) UIColor * highlightedShadowColor; 115 | [Export ("highlightedShadowColor", ArgumentSemantic.Strong)] 116 | UIColor HighlightedShadowColor { get; set; } 117 | 118 | // @property (assign, nonatomic) CGFloat kern; 119 | [Export ("kern")] 120 | nfloat Kern { get; set; } 121 | 122 | // @property (assign, nonatomic) CGFloat firstLineIndent; 123 | [Export ("firstLineIndent")] 124 | nfloat FirstLineIndent { get; set; } 125 | 126 | // @property (assign, nonatomic) CGFloat lineSpacing; 127 | [Export ("lineSpacing")] 128 | nfloat LineSpacing { get; set; } 129 | 130 | // @property (assign, nonatomic) CGFloat minimumLineHeight; 131 | [Export ("minimumLineHeight")] 132 | nfloat MinimumLineHeight { get; set; } 133 | 134 | // @property (assign, nonatomic) CGFloat maximumLineHeight; 135 | [Export ("maximumLineHeight")] 136 | nfloat MaximumLineHeight { get; set; } 137 | 138 | // @property (assign, nonatomic) CGFloat lineHeightMultiple; 139 | [Export ("lineHeightMultiple")] 140 | nfloat LineHeightMultiple { get; set; } 141 | 142 | // @property (assign, nonatomic) UIEdgeInsets textInsets; 143 | [Export ("textInsets", ArgumentSemantic.Assign)] 144 | UIEdgeInsets TextInsets { get; set; } 145 | 146 | // @property (assign, nonatomic) TTTAttributedLabelVerticalAlignment verticalAlignment; 147 | [Export ("verticalAlignment", ArgumentSemantic.Assign)] 148 | TTTAttributedLabelVerticalAlignment VerticalAlignment { get; set; } 149 | 150 | // @property (nonatomic, strong) NSAttributedString * attributedTruncationToken; 151 | [Export ("attributedTruncationToken", ArgumentSemantic.Strong)] 152 | NSAttributedString AttributedTruncationToken { get; set; } 153 | 154 | // @property (readonly, nonatomic, strong) UILongPressGestureRecognizer * longPressGestureRecognizer; 155 | [Export ("longPressGestureRecognizer", ArgumentSemantic.Strong)] 156 | UILongPressGestureRecognizer LongPressGestureRecognizer { get; } 157 | 158 | // +(CGSize)sizeThatFitsAttributedString:(NSAttributedString *)attributedString withConstraints:(CGSize)size limitedToNumberOfLines:(NSUInteger)numberOfLines; 159 | [Static] 160 | [Export ("sizeThatFitsAttributedString:withConstraints:limitedToNumberOfLines:")] 161 | CGSize SizeThatFitsAttributedString (NSAttributedString attributedString, CGSize size, nuint numberOfLines); 162 | 163 | // -(void)setText:(id)text; 164 | [Export ("setText:")] 165 | void SetText (NSAttributedString text); 166 | 167 | // -(void)setText:(id)text afterInheritingLabelAttributesAndConfiguringWithBlock:(NSMutableAttributedString *(^)(NSMutableAttributedString *))block; 168 | [Export ("setText:afterInheritingLabelAttributesAndConfiguringWithBlock:")] 169 | void SetText (NSObject text, Func block); 170 | 171 | // @property (readwrite, copy, nonatomic) NSAttributedString * attributedText; 172 | //[Export ("attributedText", ArgumentSemantic.Copy)] 173 | //NSAttributedString AttributedText { get; set; } 174 | 175 | // -(void)addLink:(TTTAttributedLabelLink *)link; 176 | [Export ("addLink:")] 177 | void AddLink (TTTAttributedLabelLink link); 178 | 179 | // -(TTTAttributedLabelLink *)addLinkWithTextCheckingResult:(NSTextCheckingResult *)result; 180 | [Export ("addLinkWithTextCheckingResult:")] 181 | TTTAttributedLabelLink AddLinkWithTextCheckingResult (NSTextCheckingResult result); 182 | 183 | // -(TTTAttributedLabelLink *)addLinkWithTextCheckingResult:(NSTextCheckingResult *)result attributes:(NSDictionary *)attributes; 184 | [Export ("addLinkWithTextCheckingResult:attributes:")] 185 | TTTAttributedLabelLink AddLinkWithTextCheckingResult (NSTextCheckingResult result, NSDictionary attributes); 186 | 187 | // -(TTTAttributedLabelLink *)addLinkToURL:(NSURL *)url withRange:(NSRange)range; 188 | [Export ("addLinkToURL:withRange:")] 189 | TTTAttributedLabelLink AddLinkToURL (NSUrl url, NSRange range); 190 | 191 | // -(TTTAttributedLabelLink *)addLinkToAddress:(NSDictionary *)addressComponents withRange:(NSRange)range; 192 | [Export ("addLinkToAddress:withRange:")] 193 | TTTAttributedLabelLink AddLinkToAddress (NSDictionary addressComponents, NSRange range); 194 | 195 | // -(TTTAttributedLabelLink *)addLinkToPhoneNumber:(NSString *)phoneNumber withRange:(NSRange)range; 196 | [Export ("addLinkToPhoneNumber:withRange:")] 197 | TTTAttributedLabelLink AddLinkToPhoneNumber (string phoneNumber, NSRange range); 198 | 199 | // -(TTTAttributedLabelLink *)addLinkToDate:(NSDate *)date withRange:(NSRange)range; 200 | [Export ("addLinkToDate:withRange:")] 201 | TTTAttributedLabelLink AddLinkToDate (NSDate date, NSRange range); 202 | 203 | // -(TTTAttributedLabelLink *)addLinkToDate:(NSDate *)date timeZone:(NSTimeZone *)timeZone duration:(NSTimeInterval)duration withRange:(NSRange)range; 204 | [Export ("addLinkToDate:timeZone:duration:withRange:")] 205 | TTTAttributedLabelLink AddLinkToDate (NSDate date, NSTimeZone timeZone, double duration, NSRange range); 206 | 207 | // -(TTTAttributedLabelLink *)addLinkToTransitInformation:(NSDictionary *)components withRange:(NSRange)range; 208 | [Export ("addLinkToTransitInformation:withRange:")] 209 | TTTAttributedLabelLink AddLinkToTransitInformation (NSDictionary components, NSRange range); 210 | 211 | // -(BOOL)containslinkAtPoint:(CGPoint)point; 212 | [Export ("containslinkAtPoint:")] 213 | bool ContainslinkAtPoint (CGPoint point); 214 | 215 | // -(TTTAttributedLabelLink *)linkAtPoint:(CGPoint)point; 216 | [Export ("linkAtPoint:")] 217 | TTTAttributedLabelLink LinkAtPoint (CGPoint point); 218 | } 219 | 220 | // @protocol TTTAttributedLabelDelegate 221 | [Protocol, Model] 222 | [BaseType (typeof (NSObject))] 223 | interface TTTAttributedLabelDelegate 224 | { 225 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url; 226 | [Export ("attributedLabel:didSelectLinkWithURL:")] 227 | void DidSelectLinkWithURL (TTTAttributedLabel label, NSUrl url); 228 | 229 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithAddress:(NSDictionary *)addressComponents; 230 | [Export ("attributedLabel:didSelectLinkWithAddress:")] 231 | void DidSelectLinkWithAddress (TTTAttributedLabel label, NSDictionary addressComponents); 232 | 233 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithPhoneNumber:(NSString *)phoneNumber; 234 | [Export ("attributedLabel:didSelectLinkWithPhoneNumber:")] 235 | void DidSelectLinkWithPhoneNumber (TTTAttributedLabel label, string phoneNumber); 236 | 237 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithDate:(NSDate *)date; 238 | [Export ("attributedLabel:didSelectLinkWithDate:")] 239 | void DidSelectLinkWithDate (TTTAttributedLabel label, NSDate date); 240 | 241 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithDate:(NSDate *)date timeZone:(NSTimeZone *)timeZone duration:(NSTimeInterval)duration; 242 | [Export ("attributedLabel:didSelectLinkWithDate:timeZone:duration:")] 243 | void DidSelectLinkWithDate (TTTAttributedLabel label, NSDate date, NSTimeZone timeZone, double duration); 244 | 245 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components; 246 | [Export ("attributedLabel:didSelectLinkWithTransitInformation:")] 247 | void DidSelectLinkWithTransitInformation (TTTAttributedLabel label, NSDictionary components); 248 | 249 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTextCheckingResult:(NSTextCheckingResult *)result; 250 | [Export ("attributedLabel:didSelectLinkWithTextCheckingResult:")] 251 | void DidSelectLinkWithTextCheckingResult (TTTAttributedLabel label, NSTextCheckingResult result); 252 | 253 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithURL:(NSURL *)url atPoint:(CGPoint)point; 254 | [Export ("attributedLabel:didLongPressLinkWithURL:atPoint:")] 255 | void DidLongPressLinkWithURL (TTTAttributedLabel label, NSUrl url, CGPoint point); 256 | 257 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithAddress:(NSDictionary *)addressComponents atPoint:(CGPoint)point; 258 | [Export ("attributedLabel:didLongPressLinkWithAddress:atPoint:")] 259 | void DidLongPressLinkWithAddress (TTTAttributedLabel label, NSDictionary addressComponents, CGPoint point); 260 | 261 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithPhoneNumber:(NSString *)phoneNumber atPoint:(CGPoint)point; 262 | [Export ("attributedLabel:didLongPressLinkWithPhoneNumber:atPoint:")] 263 | void DidLongPressLinkWithPhoneNumber (TTTAttributedLabel label, string phoneNumber, CGPoint point); 264 | 265 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithDate:(NSDate *)date atPoint:(CGPoint)point; 266 | [Export ("attributedLabel:didLongPressLinkWithDate:atPoint:")] 267 | void DidLongPressLinkWithDate (TTTAttributedLabel label, NSDate date, CGPoint point); 268 | 269 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithDate:(NSDate *)date timeZone:(NSTimeZone *)timeZone duration:(NSTimeInterval)duration atPoint:(CGPoint)point; 270 | [Export ("attributedLabel:didLongPressLinkWithDate:timeZone:duration:atPoint:")] 271 | void DidLongPressLinkWithDate (TTTAttributedLabel label, NSDate date, NSTimeZone timeZone, double duration, CGPoint point); 272 | 273 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithTransitInformation:(NSDictionary *)components atPoint:(CGPoint)point; 274 | [Export ("attributedLabel:didLongPressLinkWithTransitInformation:atPoint:")] 275 | void DidLongPressLinkWithTransitInformation (TTTAttributedLabel label, NSDictionary components, CGPoint point); 276 | 277 | // @optional -(void)attributedLabel:(TTTAttributedLabel *)label didLongPressLinkWithTextCheckingResult:(NSTextCheckingResult *)result atPoint:(CGPoint)point; 278 | [Export ("attributedLabel:didLongPressLinkWithTextCheckingResult:atPoint:")] 279 | void DidLongPressLinkWithTextCheckingResult (TTTAttributedLabel label, NSTextCheckingResult result, CGPoint point); 280 | } 281 | 282 | // @interface TTTAttributedLabelLink : NSObject 283 | [BaseType (typeof (NSObject))] 284 | interface TTTAttributedLabelLink : INSCoding 285 | { 286 | // @property (readonly, nonatomic, strong) NSTextCheckingResult * result; 287 | [Export ("result", ArgumentSemantic.Strong)] 288 | NSTextCheckingResult Result { get; } 289 | 290 | // @property (readonly, copy, nonatomic) NSDictionary * attributes; 291 | [Export ("attributes", ArgumentSemantic.Copy)] 292 | NSDictionary Attributes { get; } 293 | 294 | // @property (readonly, copy, nonatomic) NSDictionary * activeAttributes; 295 | [Export ("activeAttributes", ArgumentSemantic.Copy)] 296 | NSDictionary ActiveAttributes { get; } 297 | 298 | // @property (readonly, copy, nonatomic) NSDictionary * inactiveAttributes; 299 | [Export ("inactiveAttributes", ArgumentSemantic.Copy)] 300 | NSDictionary InactiveAttributes { get; } 301 | 302 | // @property (copy, nonatomic) NSString * accessibilityValue; 303 | [Export ("accessibilityValue")] 304 | string AccessibilityValue { get; set; } 305 | 306 | // @property (copy, nonatomic) TTTAttributedLabelLinkBlock linkTapBlock; 307 | [Export ("linkTapBlock", ArgumentSemantic.Copy)] 308 | TTTAttributedLabelLinkBlock LinkTapBlock { get; set; } 309 | 310 | // @property (copy, nonatomic) TTTAttributedLabelLinkBlock linkLongPressBlock; 311 | [Export ("linkLongPressBlock", ArgumentSemantic.Copy)] 312 | TTTAttributedLabelLinkBlock LinkLongPressBlock { get; set; } 313 | 314 | // -(instancetype)initWithAttributes:(NSDictionary *)attributes activeAttributes:(NSDictionary *)activeAttributes inactiveAttributes:(NSDictionary *)inactiveAttributes textCheckingResult:(NSTextCheckingResult *)result; 315 | [Export ("initWithAttributes:activeAttributes:inactiveAttributes:textCheckingResult:")] 316 | IntPtr Constructor (NSDictionary attributes, NSDictionary activeAttributes, NSDictionary inactiveAttributes, NSTextCheckingResult result); 317 | 318 | // -(instancetype)initWithAttributesFromLabel:(TTTAttributedLabel *)label textCheckingResult:(NSTextCheckingResult *)result; 319 | [Export ("initWithAttributesFromLabel:textCheckingResult:")] 320 | IntPtr Constructor (TTTAttributedLabel label, NSTextCheckingResult result); 321 | } 322 | 323 | // typedef void (^TTTAttributedLabelLinkBlock)(TTTAttributedLabel *, TTTAttributedLabelLink *); 324 | delegate void TTTAttributedLabelLinkBlock (TTTAttributedLabel arg0, TTTAttributedLabelLink arg1); 325 | } 326 | --------------------------------------------------------------------------------