├── .DS_Store ├── ClickableLabel.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── stevencurtis.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── stevencurtis.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── ClickableLabel ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── InteractiveLinkLabel.swift ├── InteractiveLinkTextView.swift ├── String - HTML.swift └── ViewController.swift ├── ClickableLabelTests ├── ClickableLabelTests.swift └── Info.plist ├── ClickableLabelUITests ├── ClickableLabelUITests.swift └── Info.plist └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevencurtis/ClickableLabel/590b2c37b0b066165aba6e5a2fb6a308aff8b9aa/.DS_Store -------------------------------------------------------------------------------- /ClickableLabel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CA12019C236A572F00F6143B /* String - HTML.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA12019B236A572F00F6143B /* String - HTML.swift */; }; 11 | CA12019E236A57BE00F6143B /* InteractiveLinkLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA12019D236A57BE00F6143B /* InteractiveLinkLabel.swift */; }; 12 | CA1201A0236A5B6100F6143B /* InteractiveLinkTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA12019F236A5B6100F6143B /* InteractiveLinkTextView.swift */; }; 13 | CAB190472369C0B9001FC721 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB190462369C0B9001FC721 /* AppDelegate.swift */; }; 14 | CAB190492369C0B9001FC721 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB190482369C0B9001FC721 /* ViewController.swift */; }; 15 | CAB1904C2369C0B9001FC721 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CAB1904A2369C0B9001FC721 /* Main.storyboard */; }; 16 | CAB1904E2369C0BC001FC721 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CAB1904D2369C0BC001FC721 /* Assets.xcassets */; }; 17 | CAB190512369C0BC001FC721 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CAB1904F2369C0BC001FC721 /* LaunchScreen.storyboard */; }; 18 | CAB1905C2369C0BC001FC721 /* ClickableLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB1905B2369C0BC001FC721 /* ClickableLabelTests.swift */; }; 19 | CAB190672369C0BC001FC721 /* ClickableLabelUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB190662369C0BC001FC721 /* ClickableLabelUITests.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | CAB190582369C0BC001FC721 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = CAB1903B2369C0B9001FC721 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = CAB190422369C0B9001FC721; 28 | remoteInfo = ClickableLabel; 29 | }; 30 | CAB190632369C0BC001FC721 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = CAB1903B2369C0B9001FC721 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = CAB190422369C0B9001FC721; 35 | remoteInfo = ClickableLabel; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | CA12019B236A572F00F6143B /* String - HTML.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String - HTML.swift"; sourceTree = ""; }; 41 | CA12019D236A57BE00F6143B /* InteractiveLinkLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractiveLinkLabel.swift; sourceTree = ""; }; 42 | CA12019F236A5B6100F6143B /* InteractiveLinkTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractiveLinkTextView.swift; sourceTree = ""; }; 43 | CAB190432369C0B9001FC721 /* ClickableLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClickableLabel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | CAB190462369C0B9001FC721 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 45 | CAB190482369C0B9001FC721 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 46 | CAB1904B2369C0B9001FC721 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | CAB1904D2369C0BC001FC721 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | CAB190502369C0BC001FC721 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | CAB190522369C0BC001FC721 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | CAB190572369C0BC001FC721 /* ClickableLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ClickableLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | CAB1905B2369C0BC001FC721 /* ClickableLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClickableLabelTests.swift; sourceTree = ""; }; 52 | CAB1905D2369C0BC001FC721 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | CAB190622369C0BC001FC721 /* ClickableLabelUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ClickableLabelUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | CAB190662369C0BC001FC721 /* ClickableLabelUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClickableLabelUITests.swift; sourceTree = ""; }; 55 | CAB190682369C0BC001FC721 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | CAB190402369C0B9001FC721 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | CAB190542369C0BC001FC721 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | CAB1905F2369C0BC001FC721 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | CAB1903A2369C0B9001FC721 = { 84 | isa = PBXGroup; 85 | children = ( 86 | CAB190452369C0B9001FC721 /* ClickableLabel */, 87 | CAB1905A2369C0BC001FC721 /* ClickableLabelTests */, 88 | CAB190652369C0BC001FC721 /* ClickableLabelUITests */, 89 | CAB190442369C0B9001FC721 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | CAB190442369C0B9001FC721 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | CAB190432369C0B9001FC721 /* ClickableLabel.app */, 97 | CAB190572369C0BC001FC721 /* ClickableLabelTests.xctest */, 98 | CAB190622369C0BC001FC721 /* ClickableLabelUITests.xctest */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | CAB190452369C0B9001FC721 /* ClickableLabel */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | CAB190462369C0B9001FC721 /* AppDelegate.swift */, 107 | CAB190482369C0B9001FC721 /* ViewController.swift */, 108 | CA12019B236A572F00F6143B /* String - HTML.swift */, 109 | CA12019D236A57BE00F6143B /* InteractiveLinkLabel.swift */, 110 | CA12019F236A5B6100F6143B /* InteractiveLinkTextView.swift */, 111 | CAB1904A2369C0B9001FC721 /* Main.storyboard */, 112 | CAB1904D2369C0BC001FC721 /* Assets.xcassets */, 113 | CAB1904F2369C0BC001FC721 /* LaunchScreen.storyboard */, 114 | CAB190522369C0BC001FC721 /* Info.plist */, 115 | ); 116 | path = ClickableLabel; 117 | sourceTree = ""; 118 | }; 119 | CAB1905A2369C0BC001FC721 /* ClickableLabelTests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | CAB1905B2369C0BC001FC721 /* ClickableLabelTests.swift */, 123 | CAB1905D2369C0BC001FC721 /* Info.plist */, 124 | ); 125 | path = ClickableLabelTests; 126 | sourceTree = ""; 127 | }; 128 | CAB190652369C0BC001FC721 /* ClickableLabelUITests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | CAB190662369C0BC001FC721 /* ClickableLabelUITests.swift */, 132 | CAB190682369C0BC001FC721 /* Info.plist */, 133 | ); 134 | path = ClickableLabelUITests; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | CAB190422369C0B9001FC721 /* ClickableLabel */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = CAB1906B2369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabel" */; 143 | buildPhases = ( 144 | CAB1903F2369C0B9001FC721 /* Sources */, 145 | CAB190402369C0B9001FC721 /* Frameworks */, 146 | CAB190412369C0B9001FC721 /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = ClickableLabel; 153 | productName = ClickableLabel; 154 | productReference = CAB190432369C0B9001FC721 /* ClickableLabel.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | CAB190562369C0BC001FC721 /* ClickableLabelTests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = CAB1906E2369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabelTests" */; 160 | buildPhases = ( 161 | CAB190532369C0BC001FC721 /* Sources */, 162 | CAB190542369C0BC001FC721 /* Frameworks */, 163 | CAB190552369C0BC001FC721 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | CAB190592369C0BC001FC721 /* PBXTargetDependency */, 169 | ); 170 | name = ClickableLabelTests; 171 | productName = ClickableLabelTests; 172 | productReference = CAB190572369C0BC001FC721 /* ClickableLabelTests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | CAB190612369C0BC001FC721 /* ClickableLabelUITests */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = CAB190712369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabelUITests" */; 178 | buildPhases = ( 179 | CAB1905E2369C0BC001FC721 /* Sources */, 180 | CAB1905F2369C0BC001FC721 /* Frameworks */, 181 | CAB190602369C0BC001FC721 /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | CAB190642369C0BC001FC721 /* PBXTargetDependency */, 187 | ); 188 | name = ClickableLabelUITests; 189 | productName = ClickableLabelUITests; 190 | productReference = CAB190622369C0BC001FC721 /* ClickableLabelUITests.xctest */; 191 | productType = "com.apple.product-type.bundle.ui-testing"; 192 | }; 193 | /* End PBXNativeTarget section */ 194 | 195 | /* Begin PBXProject section */ 196 | CAB1903B2369C0B9001FC721 /* Project object */ = { 197 | isa = PBXProject; 198 | attributes = { 199 | LastSwiftUpdateCheck = 1020; 200 | LastUpgradeCheck = 1020; 201 | ORGANIZATIONNAME = "Steven Curtis"; 202 | TargetAttributes = { 203 | CAB190422369C0B9001FC721 = { 204 | CreatedOnToolsVersion = 10.2.1; 205 | }; 206 | CAB190562369C0BC001FC721 = { 207 | CreatedOnToolsVersion = 10.2.1; 208 | TestTargetID = CAB190422369C0B9001FC721; 209 | }; 210 | CAB190612369C0BC001FC721 = { 211 | CreatedOnToolsVersion = 10.2.1; 212 | TestTargetID = CAB190422369C0B9001FC721; 213 | }; 214 | }; 215 | }; 216 | buildConfigurationList = CAB1903E2369C0B9001FC721 /* Build configuration list for PBXProject "ClickableLabel" */; 217 | compatibilityVersion = "Xcode 9.3"; 218 | developmentRegion = en; 219 | hasScannedForEncodings = 0; 220 | knownRegions = ( 221 | en, 222 | Base, 223 | ); 224 | mainGroup = CAB1903A2369C0B9001FC721; 225 | productRefGroup = CAB190442369C0B9001FC721 /* Products */; 226 | projectDirPath = ""; 227 | projectRoot = ""; 228 | targets = ( 229 | CAB190422369C0B9001FC721 /* ClickableLabel */, 230 | CAB190562369C0BC001FC721 /* ClickableLabelTests */, 231 | CAB190612369C0BC001FC721 /* ClickableLabelUITests */, 232 | ); 233 | }; 234 | /* End PBXProject section */ 235 | 236 | /* Begin PBXResourcesBuildPhase section */ 237 | CAB190412369C0B9001FC721 /* Resources */ = { 238 | isa = PBXResourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | CAB190512369C0BC001FC721 /* LaunchScreen.storyboard in Resources */, 242 | CAB1904E2369C0BC001FC721 /* Assets.xcassets in Resources */, 243 | CAB1904C2369C0B9001FC721 /* Main.storyboard in Resources */, 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | }; 247 | CAB190552369C0BC001FC721 /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | CAB190602369C0BC001FC721 /* Resources */ = { 255 | isa = PBXResourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | /* End PBXResourcesBuildPhase section */ 262 | 263 | /* Begin PBXSourcesBuildPhase section */ 264 | CAB1903F2369C0B9001FC721 /* Sources */ = { 265 | isa = PBXSourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | CA12019C236A572F00F6143B /* String - HTML.swift in Sources */, 269 | CA12019E236A57BE00F6143B /* InteractiveLinkLabel.swift in Sources */, 270 | CAB190492369C0B9001FC721 /* ViewController.swift in Sources */, 271 | CAB190472369C0B9001FC721 /* AppDelegate.swift in Sources */, 272 | CA1201A0236A5B6100F6143B /* InteractiveLinkTextView.swift in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | CAB190532369C0BC001FC721 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | CAB1905C2369C0BC001FC721 /* ClickableLabelTests.swift in Sources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | CAB1905E2369C0BC001FC721 /* Sources */ = { 285 | isa = PBXSourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | CAB190672369C0BC001FC721 /* ClickableLabelUITests.swift in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXSourcesBuildPhase section */ 293 | 294 | /* Begin PBXTargetDependency section */ 295 | CAB190592369C0BC001FC721 /* PBXTargetDependency */ = { 296 | isa = PBXTargetDependency; 297 | target = CAB190422369C0B9001FC721 /* ClickableLabel */; 298 | targetProxy = CAB190582369C0BC001FC721 /* PBXContainerItemProxy */; 299 | }; 300 | CAB190642369C0BC001FC721 /* PBXTargetDependency */ = { 301 | isa = PBXTargetDependency; 302 | target = CAB190422369C0B9001FC721 /* ClickableLabel */; 303 | targetProxy = CAB190632369C0BC001FC721 /* PBXContainerItemProxy */; 304 | }; 305 | /* End PBXTargetDependency section */ 306 | 307 | /* Begin PBXVariantGroup section */ 308 | CAB1904A2369C0B9001FC721 /* Main.storyboard */ = { 309 | isa = PBXVariantGroup; 310 | children = ( 311 | CAB1904B2369C0B9001FC721 /* Base */, 312 | ); 313 | name = Main.storyboard; 314 | sourceTree = ""; 315 | }; 316 | CAB1904F2369C0BC001FC721 /* LaunchScreen.storyboard */ = { 317 | isa = PBXVariantGroup; 318 | children = ( 319 | CAB190502369C0BC001FC721 /* Base */, 320 | ); 321 | name = LaunchScreen.storyboard; 322 | sourceTree = ""; 323 | }; 324 | /* End PBXVariantGroup section */ 325 | 326 | /* Begin XCBuildConfiguration section */ 327 | CAB190692369C0BC001FC721 /* Debug */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_ANALYZER_NONNULL = YES; 332 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_ENABLE_OBJC_WEAK = YES; 338 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 339 | CLANG_WARN_BOOL_CONVERSION = YES; 340 | CLANG_WARN_COMMA = YES; 341 | CLANG_WARN_CONSTANT_CONVERSION = YES; 342 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 343 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 344 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 345 | CLANG_WARN_EMPTY_BODY = YES; 346 | CLANG_WARN_ENUM_CONVERSION = YES; 347 | CLANG_WARN_INFINITE_RECURSION = YES; 348 | CLANG_WARN_INT_CONVERSION = YES; 349 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 350 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 351 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 352 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 353 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 354 | CLANG_WARN_STRICT_PROTOTYPES = YES; 355 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 356 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 357 | CLANG_WARN_UNREACHABLE_CODE = YES; 358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 359 | CODE_SIGN_IDENTITY = "iPhone Developer"; 360 | COPY_PHASE_STRIP = NO; 361 | DEBUG_INFORMATION_FORMAT = dwarf; 362 | ENABLE_STRICT_OBJC_MSGSEND = YES; 363 | ENABLE_TESTABILITY = YES; 364 | GCC_C_LANGUAGE_STANDARD = gnu11; 365 | GCC_DYNAMIC_NO_PIC = NO; 366 | GCC_NO_COMMON_BLOCKS = YES; 367 | GCC_OPTIMIZATION_LEVEL = 0; 368 | GCC_PREPROCESSOR_DEFINITIONS = ( 369 | "DEBUG=1", 370 | "$(inherited)", 371 | ); 372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 374 | GCC_WARN_UNDECLARED_SELECTOR = YES; 375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 376 | GCC_WARN_UNUSED_FUNCTION = YES; 377 | GCC_WARN_UNUSED_VARIABLE = YES; 378 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 379 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 380 | MTL_FAST_MATH = YES; 381 | ONLY_ACTIVE_ARCH = YES; 382 | SDKROOT = iphoneos; 383 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 384 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 385 | }; 386 | name = Debug; 387 | }; 388 | CAB1906A2369C0BC001FC721 /* Release */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_ANALYZER_NONNULL = YES; 393 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 395 | CLANG_CXX_LIBRARY = "libc++"; 396 | CLANG_ENABLE_MODULES = YES; 397 | CLANG_ENABLE_OBJC_ARC = YES; 398 | CLANG_ENABLE_OBJC_WEAK = YES; 399 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_COMMA = YES; 402 | CLANG_WARN_CONSTANT_CONVERSION = YES; 403 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 405 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 406 | CLANG_WARN_EMPTY_BODY = YES; 407 | CLANG_WARN_ENUM_CONVERSION = YES; 408 | CLANG_WARN_INFINITE_RECURSION = YES; 409 | CLANG_WARN_INT_CONVERSION = YES; 410 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 411 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 412 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 413 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 414 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 415 | CLANG_WARN_STRICT_PROTOTYPES = YES; 416 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 417 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | CODE_SIGN_IDENTITY = "iPhone Developer"; 421 | COPY_PHASE_STRIP = NO; 422 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 423 | ENABLE_NS_ASSERTIONS = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu11; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 434 | MTL_ENABLE_DEBUG_INFO = NO; 435 | MTL_FAST_MATH = YES; 436 | SDKROOT = iphoneos; 437 | SWIFT_COMPILATION_MODE = wholemodule; 438 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 439 | VALIDATE_PRODUCT = YES; 440 | }; 441 | name = Release; 442 | }; 443 | CAB1906C2369C0BC001FC721 /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 447 | CODE_SIGN_STYLE = Automatic; 448 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 449 | INFOPLIST_FILE = ClickableLabel/Info.plist; 450 | LD_RUNPATH_SEARCH_PATHS = ( 451 | "$(inherited)", 452 | "@executable_path/Frameworks", 453 | ); 454 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabel; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | SWIFT_VERSION = 5.0; 457 | TARGETED_DEVICE_FAMILY = "1,2"; 458 | }; 459 | name = Debug; 460 | }; 461 | CAB1906D2369C0BC001FC721 /* Release */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | CODE_SIGN_STYLE = Automatic; 466 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 467 | INFOPLIST_FILE = ClickableLabel/Info.plist; 468 | LD_RUNPATH_SEARCH_PATHS = ( 469 | "$(inherited)", 470 | "@executable_path/Frameworks", 471 | ); 472 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabel; 473 | PRODUCT_NAME = "$(TARGET_NAME)"; 474 | SWIFT_VERSION = 5.0; 475 | TARGETED_DEVICE_FAMILY = "1,2"; 476 | }; 477 | name = Release; 478 | }; 479 | CAB1906F2369C0BC001FC721 /* Debug */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 483 | BUNDLE_LOADER = "$(TEST_HOST)"; 484 | CODE_SIGN_STYLE = Automatic; 485 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 486 | INFOPLIST_FILE = ClickableLabelTests/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = ( 488 | "$(inherited)", 489 | "@executable_path/Frameworks", 490 | "@loader_path/Frameworks", 491 | ); 492 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabelTests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | SWIFT_VERSION = 5.0; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ClickableLabel.app/ClickableLabel"; 497 | }; 498 | name = Debug; 499 | }; 500 | CAB190702369C0BC001FC721 /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 504 | BUNDLE_LOADER = "$(TEST_HOST)"; 505 | CODE_SIGN_STYLE = Automatic; 506 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 507 | INFOPLIST_FILE = ClickableLabelTests/Info.plist; 508 | LD_RUNPATH_SEARCH_PATHS = ( 509 | "$(inherited)", 510 | "@executable_path/Frameworks", 511 | "@loader_path/Frameworks", 512 | ); 513 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabelTests; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | SWIFT_VERSION = 5.0; 516 | TARGETED_DEVICE_FAMILY = "1,2"; 517 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ClickableLabel.app/ClickableLabel"; 518 | }; 519 | name = Release; 520 | }; 521 | CAB190722369C0BC001FC721 /* Debug */ = { 522 | isa = XCBuildConfiguration; 523 | buildSettings = { 524 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 525 | CODE_SIGN_STYLE = Automatic; 526 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 527 | INFOPLIST_FILE = ClickableLabelUITests/Info.plist; 528 | LD_RUNPATH_SEARCH_PATHS = ( 529 | "$(inherited)", 530 | "@executable_path/Frameworks", 531 | "@loader_path/Frameworks", 532 | ); 533 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabelUITests; 534 | PRODUCT_NAME = "$(TARGET_NAME)"; 535 | SWIFT_VERSION = 5.0; 536 | TARGETED_DEVICE_FAMILY = "1,2"; 537 | TEST_TARGET_NAME = ClickableLabel; 538 | }; 539 | name = Debug; 540 | }; 541 | CAB190732369C0BC001FC721 /* Release */ = { 542 | isa = XCBuildConfiguration; 543 | buildSettings = { 544 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 545 | CODE_SIGN_STYLE = Automatic; 546 | DEVELOPMENT_TEAM = UW69ZFFDZJ; 547 | INFOPLIST_FILE = ClickableLabelUITests/Info.plist; 548 | LD_RUNPATH_SEARCH_PATHS = ( 549 | "$(inherited)", 550 | "@executable_path/Frameworks", 551 | "@loader_path/Frameworks", 552 | ); 553 | PRODUCT_BUNDLE_IDENTIFIER = com.studeapps.ClickableLabelUITests; 554 | PRODUCT_NAME = "$(TARGET_NAME)"; 555 | SWIFT_VERSION = 5.0; 556 | TARGETED_DEVICE_FAMILY = "1,2"; 557 | TEST_TARGET_NAME = ClickableLabel; 558 | }; 559 | name = Release; 560 | }; 561 | /* End XCBuildConfiguration section */ 562 | 563 | /* Begin XCConfigurationList section */ 564 | CAB1903E2369C0B9001FC721 /* Build configuration list for PBXProject "ClickableLabel" */ = { 565 | isa = XCConfigurationList; 566 | buildConfigurations = ( 567 | CAB190692369C0BC001FC721 /* Debug */, 568 | CAB1906A2369C0BC001FC721 /* Release */, 569 | ); 570 | defaultConfigurationIsVisible = 0; 571 | defaultConfigurationName = Release; 572 | }; 573 | CAB1906B2369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabel" */ = { 574 | isa = XCConfigurationList; 575 | buildConfigurations = ( 576 | CAB1906C2369C0BC001FC721 /* Debug */, 577 | CAB1906D2369C0BC001FC721 /* Release */, 578 | ); 579 | defaultConfigurationIsVisible = 0; 580 | defaultConfigurationName = Release; 581 | }; 582 | CAB1906E2369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabelTests" */ = { 583 | isa = XCConfigurationList; 584 | buildConfigurations = ( 585 | CAB1906F2369C0BC001FC721 /* Debug */, 586 | CAB190702369C0BC001FC721 /* Release */, 587 | ); 588 | defaultConfigurationIsVisible = 0; 589 | defaultConfigurationName = Release; 590 | }; 591 | CAB190712369C0BC001FC721 /* Build configuration list for PBXNativeTarget "ClickableLabelUITests" */ = { 592 | isa = XCConfigurationList; 593 | buildConfigurations = ( 594 | CAB190722369C0BC001FC721 /* Debug */, 595 | CAB190732369C0BC001FC721 /* Release */, 596 | ); 597 | defaultConfigurationIsVisible = 0; 598 | defaultConfigurationName = Release; 599 | }; 600 | /* End XCConfigurationList section */ 601 | }; 602 | rootObject = CAB1903B2369C0B9001FC721 /* Project object */; 603 | } 604 | -------------------------------------------------------------------------------- /ClickableLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ClickableLabel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ClickableLabel.xcodeproj/project.xcworkspace/xcuserdata/stevencurtis.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevencurtis/ClickableLabel/590b2c37b0b066165aba6e5a2fb6a308aff8b9aa/ClickableLabel.xcodeproj/project.xcworkspace/xcuserdata/stevencurtis.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ClickableLabel.xcodeproj/xcuserdata/stevencurtis.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ClickableLabel.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ClickableLabel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ClickableLabel 4 | // 5 | // Created by Steven Curtis on 30/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ClickableLabel/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ClickableLabel/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ClickableLabel/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /ClickableLabel/Base.lproj/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 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 43 | 44 | 45 | 46 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 65 | 66 | 67 | 68 | 74 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /ClickableLabel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ClickableLabel/InteractiveLinkLabel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InteractiveLinkLabel.swift 3 | // ClickableLabel 4 | // 5 | // Created by Steven Curtis on 31/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class InteractiveLinkLabel: UILabel { 12 | 13 | required init(coder aDecoder: NSCoder) { 14 | super.init(coder: aDecoder)! 15 | self.configure() 16 | } 17 | 18 | override init(frame: CGRect) { 19 | super.init(frame: frame) 20 | self.configure() 21 | } 22 | 23 | func configure() { 24 | isUserInteractionEnabled = true 25 | } 26 | 27 | override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { 28 | 29 | let superBool = super.point(inside: point, with: event) 30 | 31 | // Configure NSTextContainer 32 | let textContainer = NSTextContainer(size: bounds.size) 33 | textContainer.lineFragmentPadding = 0.0 34 | textContainer.lineBreakMode = lineBreakMode 35 | textContainer.maximumNumberOfLines = numberOfLines 36 | 37 | // Configure NSLayoutManager and add the text container 38 | let layoutManager = NSLayoutManager() 39 | layoutManager.addTextContainer(textContainer) 40 | 41 | guard let attributedText = attributedText else {return false} 42 | 43 | // Configure NSTextStorage and apply the layout manager 44 | let textStorage = NSTextStorage(attributedString: attributedText) 45 | textStorage.addAttribute(NSAttributedString.Key.font, value: font!, range: NSMakeRange(0, attributedText.length)) 46 | textStorage.addLayoutManager(layoutManager) 47 | 48 | // get the tapped character location 49 | let locationOfTouchInLabel = point 50 | 51 | // account for text alignment and insets 52 | let textBoundingBox = layoutManager.usedRect(for: textContainer) 53 | var alignmentOffset: CGFloat! 54 | switch textAlignment { 55 | case .left, .natural, .justified: 56 | alignmentOffset = 0.0 57 | case .center: 58 | alignmentOffset = 0.5 59 | case .right: 60 | alignmentOffset = 1.0 61 | @unknown default: 62 | fatalError() 63 | } 64 | 65 | let xOffset = ((bounds.size.width - textBoundingBox.size.width) * alignmentOffset) - textBoundingBox.origin.x 66 | let yOffset = ((bounds.size.height - textBoundingBox.size.height) * alignmentOffset) - textBoundingBox.origin.y 67 | let locationOfTouchInTextContainer = CGPoint(x: locationOfTouchInLabel.x - xOffset, y: locationOfTouchInLabel.y - yOffset) 68 | 69 | // work out which character was tapped 70 | let characterIndex = layoutManager.characterIndex(for: locationOfTouchInTextContainer, in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) 71 | 72 | // work out how many characters are in the string up to and including the line tapped, to ensure we are not off the end of the character string 73 | let lineTapped = Int(ceil(locationOfTouchInLabel.y / font.lineHeight)) - 1 74 | let rightMostPointInLineTapped = CGPoint(x: bounds.size.width, y: font.lineHeight * CGFloat(lineTapped)) 75 | let charsInLineTapped = layoutManager.characterIndex(for: rightMostPointInLineTapped, in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) 76 | 77 | guard characterIndex < charsInLineTapped else {return false} 78 | 79 | let attributeName = NSAttributedString.Key.link 80 | 81 | let attributeValue = self.attributedText?.attribute(attributeName, at: characterIndex, effectiveRange: nil) 82 | 83 | if let value = attributeValue { 84 | if let url = value as? URL { 85 | UIApplication.shared.open(url) 86 | } 87 | } 88 | 89 | return superBool 90 | 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /ClickableLabel/InteractiveLinkTextView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InteractiveLinkTextView.swift 3 | // ClickableLabel 4 | // 5 | // Created by Steven Curtis on 31/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class InteractiveLinkTextView: UITextView { 12 | 13 | override init(frame: CGRect, textContainer: NSTextContainer?) { 14 | super.init(frame: frame, textContainer: textContainer) 15 | configure() 16 | } 17 | 18 | required init?(coder aDecoder: NSCoder) { 19 | super.init(coder: aDecoder) 20 | configure() 21 | } 22 | 23 | func configure() { 24 | isScrollEnabled = false 25 | isEditable = false 26 | isSelectable = false 27 | isUserInteractionEnabled = true 28 | } 29 | 30 | override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { 31 | let superBool = super.point(inside: point, with: event) 32 | 33 | var location = point 34 | location.x -= self.textContainerInset.left 35 | location.y -= self.textContainerInset.top 36 | 37 | let characterIndex = layoutManager.characterIndex(for: location, in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil) 38 | guard characterIndex < textStorage.length else {return false} 39 | let attributes = textStorage.attributes(at: characterIndex, effectiveRange: nil) 40 | 41 | let attributeName = NSAttributedString.Key.link 42 | 43 | let attributeValue = self.attributedText?.attribute(attributeName, at: characterIndex, effectiveRange: nil) 44 | 45 | if let value = attributeValue { 46 | if let url = value as? URL { 47 | UIApplication.shared.open(url) 48 | } 49 | } 50 | 51 | return superBool && attributes[NSAttributedString.Key.underlineStyle ] != nil 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /ClickableLabel/String - HTML.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String - HTML.swift 3 | // ClickableLabel 4 | // 5 | // Created by Steven Curtis on 31/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension String{ 12 | var html: NSMutableAttributedString? { 13 | do { 14 | guard let data = data(using: String.Encoding.utf8) else { 15 | return nil 16 | } 17 | return try NSMutableAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) 18 | } catch { 19 | print ("Error \(error)") 20 | return nil 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ClickableLabel/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ClickableLabel 4 | // 5 | // Created by Steven Curtis on 30/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var gestureLabel: UILabel! 14 | @IBOutlet weak var gestureTextView: UITextView! 15 | @IBOutlet weak var attributedTextView: UITextView! 16 | @IBOutlet weak var attributedLabel: UILabel! 17 | @IBOutlet weak var interactiveLinkLabel: InteractiveLinkLabel! 18 | @IBOutlet weak var interactiveLinkTextView: UITextView! 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | // Tap gesture recognizers 24 | let tapLabel = UITapGestureRecognizer(target: self, action: #selector(ViewController.tapFunction)) 25 | let tapTV = UITapGestureRecognizer(target: self, action: #selector(ViewController.tapFunction)) 26 | 27 | // Gesture recognizer Label 28 | gestureLabel.isUserInteractionEnabled = true 29 | gestureLabel.addGestureRecognizer(tapLabel) 30 | gestureLabel.text = "Gesture recognizer label" 31 | 32 | // Gesture recognizer TextView 33 | gestureTextView.isUserInteractionEnabled = true 34 | gestureTextView.isEditable = false 35 | gestureTextView.addGestureRecognizer(tapTV) 36 | gestureTextView.text = "Gesture recognizer text view" 37 | 38 | let plainAttributedString = NSMutableAttributedString(string: "This is a link: ", attributes: nil) 39 | let string = "A link to Google" 40 | let attributedLinkString = NSMutableAttributedString(string: string, attributes:[NSAttributedString.Key.link: URL(string: "http://www.google.com")!]) 41 | let fullAttributedString = NSMutableAttributedString() 42 | fullAttributedString.append(plainAttributedString) 43 | fullAttributedString.append(attributedLinkString) 44 | attributedLabel.isUserInteractionEnabled = true 45 | attributedLabel.attributedText = fullAttributedString 46 | 47 | attributedTextView.isUserInteractionEnabled = true 48 | attributedTextView.isEditable = false 49 | attributedTextView.attributedText = fullAttributedString 50 | 51 | interactiveLinkLabel.attributedText = fullAttributedString 52 | 53 | interactiveLinkTextView.isUserInteractionEnabled = true 54 | interactiveLinkTextView.isEditable = false 55 | interactiveLinkTextView.attributedText = fullAttributedString 56 | } 57 | 58 | @IBAction func tapFunction(sender: UITapGestureRecognizer) { 59 | let url = URL(string: "http://www.google.com")! 60 | UIApplication.shared.open(url) 61 | 62 | } 63 | 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /ClickableLabelTests/ClickableLabelTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ClickableLabelTests.swift 3 | // ClickableLabelTests 4 | // 5 | // Created by Steven Curtis on 30/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import ClickableLabel 11 | 12 | class ClickableLabelTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ClickableLabelTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ClickableLabelUITests/ClickableLabelUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ClickableLabelUITests.swift 3 | // ClickableLabelUITests 4 | // 5 | // Created by Steven Curtis on 30/10/2019. 6 | // Copyright © 2019 Steven Curtis. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class ClickableLabelUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 20 | XCUIApplication().launch() 21 | 22 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 23 | } 24 | 25 | override func tearDown() { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | } 28 | 29 | func testExample() { 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ClickableLabelUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ClickableLabel 2 | A github repo linked to the Medium post 3 | 4 | [Medium Post](https://medium.com/@stevenpcurtis.sc/clickable-link-on-a-swift-label-or-textview-98bbb067451d) --------------------------------------------------------------------------------