| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | Pod::Spec.new do |s| | |
| 2 | 2 | s.name = 'AttributedTextView' | |
| 3 | - s.version = '0.9.1' | ||
| 3 | + s.version = '0.9.2' | ||
| 4 | 4 | s.license = { :type => "MIT", :file => "LICENSE" } | |
| 5 | 5 | s.summary = 'Easiest way to create an attributed UILabel or UITextView (with support for multiple links and HTML)' | |
| 6 | 6 | s.homepage = 'https://github.com/evermeer/AttributedTextView' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,7 @@ | |||
| 41 | 41 | 7FA506E61E695CEB003D83E7 /* AttributedLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FA506E51E695CEB003D83E7 /* AttributedLabel.swift */; }; | |
| 42 | 42 | 7FA506E81E696EA2003D83E7 /* AttributedTextViewSubclassDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FA506E71E696EA2003D83E7 /* AttributedTextViewSubclassDemo.swift */; }; | |
| 43 | 43 | 7FA506EA1E696EBD003D83E7 /* AttributedLabelSubclassDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FA506E91E696EBD003D83E7 /* AttributedLabelSubclassDemo.swift */; }; | |
| 44 | + 7FA64F2E20D7DA7200E9345A /* String+NSRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FA64F2D20D7DA7200E9345A /* String+NSRange.swift */; }; | ||
| 44 | 45 | 7FD407B01E0C280E00AEBF1B /* Sample5.png in Resources */ = {isa = PBXBuildFile; fileRef = 7FD407AF1E0C280E00AEBF1B /* Sample5.png */; }; | |
| 45 | 46 | /* End PBXBuildFile section */ | |
| 46 | 47 | ||
@@ -71,6 +72,7 @@ | |||
| 71 | 72 | 7FA506E51E695CEB003D83E7 /* AttributedLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedLabel.swift; sourceTree = "<group>"; }; | |
| 72 | 73 | 7FA506E71E696EA2003D83E7 /* AttributedTextViewSubclassDemo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedTextViewSubclassDemo.swift; sourceTree = "<group>"; }; | |
| 73 | 74 | 7FA506E91E696EBD003D83E7 /* AttributedLabelSubclassDemo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedLabelSubclassDemo.swift; sourceTree = "<group>"; }; | |
| 75 | + 7FA64F2D20D7DA7200E9345A /* String+NSRange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+NSRange.swift"; sourceTree = "<group>"; }; | ||
| 74 | 76 | 7FD407AF1E0C280E00AEBF1B /* Sample5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Sample5.png; sourceTree = "<group>"; }; | |
| 75 | 77 | 7FD880471DEF968500D299E1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; | |
| 76 | 78 | 7FDAE1351DEF192A00CB46B6 /* Sample1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Sample1.png; sourceTree = "<group>"; }; | |
@@ -170,6 +172,7 @@ | |||
| 170 | 172 | 7FA506E51E695CEB003D83E7 /* AttributedLabel.swift */, | |
| 171 | 173 | 1304F89F1F86096800347B42 /* CGFloatDP.swift */, | |
| 172 | 174 | 7F198B63205035240009ACF3 /* NSAttributedString+Html.swift */, | |
| 175 | + 7FA64F2D20D7DA7200E9345A /* String+NSRange.swift */, | ||
| 173 | 176 | ); | |
| 174 | 177 | name = Core; | |
| 175 | 178 | sourceTree = "<group>"; | |
@@ -455,6 +458,7 @@ | |||
| 455 | 458 | 7F1C64871DEC722F002A1A59 /* AttributedTextView.swift in Sources */, | |
| 456 | 459 | 1304F8A01F86096800347B42 /* CGFloatDP.swift in Sources */, | |
| 457 | 460 | 7F198B64205035240009ACF3 /* NSAttributedString+Html.swift in Sources */, | |
| 461 | + 7FA64F2E20D7DA7200E9345A /* String+NSRange.swift in Sources */, | ||
| 458 | 462 | 7F1C64791DEC722F002A1A59 /* Attributer.swift in Sources */, | |
| 459 | 463 | ); | |
| 460 | 464 | runOnlyForDeploymentPostprocessing = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -527,8 +527,7 @@ open class Attributer { | |||
| 527 | 527 | */ | |
| 528 | 528 | open func makeInteract(_ callback: @escaping ((_ link: String) -> ())) -> Attributer { | |
| 529 | 529 | for nsRange in self.ranges { | |
| 530 | - let iRange = self.attributedText.string.range(from: nsRange) | ||
| 531 | - let unEscapedString = self.attributedText.string.substring(with: iRange!) | ||
| 530 | + let unEscapedString = (self.attributedText.string as NSString).substring(with: nsRange) | ||
| 532 | 531 | let escapedString = unEscapedString.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlHostAllowed) ?? "" | |
| 533 | 532 | self.attributedText.addAttribute(NSAttributedStringKey.link, value: "AttributedTextView:\(escapedString)", range: nsRange) | |
| 534 | 533 | urlCallbacks[unEscapedString] = callback | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + // | ||
| 2 | + // String+NSRange.swift | ||
| 3 | + // AttributedTextView-iOS | ||
| 4 | + // | ||
| 5 | + // Created by Edwin Vermeer on 18-06-18. | ||
| 6 | + // Copyright © 2018 evermeer. All rights reserved. | ||
| 7 | + // | ||
| 8 | + | ||
| 9 | + import Foundation | ||
| 10 | + | ||
| 11 | + public extension String { | ||
| 12 | + func substring(with nsrange: NSRange) -> Substring? { | ||
| 13 | + guard let range = Range(nsrange, in: self) else { return nil } | ||
| 14 | + return self[range] | ||
| 15 | + } | ||
| 16 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments