├── .gitignore ├── CHANGELOG.md ├── Default-568h@2x.png ├── GrowingTextViewHandler-Swift.podspec ├── GrowingTextViewHandler.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── GrowingTextViewHandler.xcscheme ├── GrowingTextViewHandler ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── FormTableViewCell.swift ├── FormViewController.swift ├── GrowingTextViewHandler.h ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Source │ └── GrowingTextViewHandler.swift └── ViewController.swift ├── GrowingTextViewHandlerTests ├── GrowingTextViewHandlerTests.swift └── Info.plist ├── README.md └── license.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | version 1.2: 2 | Support for swift 4 3 | 4 | version 1.1: 5 | Support for swift 3 6 | Carthage support 7 | 8 | version 1.0.3: 9 | Support for swift 2.0 10 | Detailed documentation 11 | 12 | version 1.0.2: 13 | Update logic for calculation of line number 14 | 15 | version 1.0.1: 16 | First version 17 | -------------------------------------------------------------------------------- /Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hsusmita/GrowingTextViewHandler/ce94a208b3663cc7a6d152e68bdb124aea39c7bb/Default-568h@2x.png -------------------------------------------------------------------------------- /GrowingTextViewHandler-Swift.podspec: -------------------------------------------------------------------------------- 1 | Pod:: Spec.new do |spec| 2 | spec.platform = 'ios', '8.0' 3 | spec.name = 'GrowingTextViewHandler-Swift' 4 | spec.version = '1.2' 5 | spec.summary = 'An NSObject subclass to handle resizing of UITextView as the user types in.' 6 | spec.author = { 7 | 'Susmita Horrow' => 'susmita.horrow@gmail.com' 8 | } 9 | spec.license = 'MIT' 10 | spec.homepage = 'https://github.com/hsusmita/GrowingTextViewHandler' 11 | spec.source = { 12 | :git => 'https://github.com/hsusmita/GrowingTextViewHandler.git', 13 | :tag => '1.2' 14 | } 15 | spec.ios.deployment_target = '8.0' 16 | spec.source_files = 'GrowingTextViewHandler/Source/*' 17 | spec.requires_arc = true 18 | spec.swift_version = '4.2' 19 | end 20 | 21 | 22 | -------------------------------------------------------------------------------- /GrowingTextViewHandler.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4EF6FE661D586146003863CC /* FormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EF6FE651D586146003863CC /* FormViewController.swift */; }; 11 | 4EF6FE681D586229003863CC /* FormTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EF6FE671D586229003863CC /* FormTableViewCell.swift */; }; 12 | 69CEFFCB1A9D9F03003B4786 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CEFFCA1A9D9F03003B4786 /* AppDelegate.swift */; }; 13 | 69CEFFCD1A9D9F03003B4786 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CEFFCC1A9D9F03003B4786 /* ViewController.swift */; }; 14 | 69CEFFD01A9D9F03003B4786 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 69CEFFCE1A9D9F03003B4786 /* Main.storyboard */; }; 15 | 69CEFFD21A9D9F03003B4786 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 69CEFFD11A9D9F03003B4786 /* Images.xcassets */; }; 16 | 69CEFFD51A9D9F03003B4786 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 69CEFFD31A9D9F03003B4786 /* LaunchScreen.xib */; }; 17 | 69CEFFE11A9D9F03003B4786 /* GrowingTextViewHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CEFFE01A9D9F03003B4786 /* GrowingTextViewHandlerTests.swift */; }; 18 | 9A8A4EDD1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A8A4EDB1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 19 | 9A8A4EE21DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 20 | 9A8A4EE61DC4A0BB00A6D5B5 /* GrowingTextViewHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CEFFEB1A9D9FB1003B4786 /* GrowingTextViewHandler.swift */; }; 21 | 9A8A4EE71DC4A24500A6D5B5 /* GrowingTextViewHandler.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */; }; 22 | 9A9324641DD35A5B00CB1B99 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 69CEFFDB1A9D9F03003B4786 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 69CEFFBD1A9D9F03003B4786 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 69CEFFC41A9D9F03003B4786; 31 | remoteInfo = GrowingTextViewHandler; 32 | }; 33 | 9A8A4EDE1DC4A0B000A6D5B5 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 69CEFFBD1A9D9F03003B4786 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 9A8A4ED81DC4A0B000A6D5B5; 38 | remoteInfo = GrowingTextViewHandler; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXCopyFilesBuildPhase section */ 43 | 9A8A4EE11DC4A0B000A6D5B5 /* Embed Frameworks */ = { 44 | isa = PBXCopyFilesBuildPhase; 45 | buildActionMask = 2147483647; 46 | dstPath = ""; 47 | dstSubfolderSpec = 10; 48 | files = ( 49 | 9A8A4EE21DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework in Embed Frameworks */, 50 | ); 51 | name = "Embed Frameworks"; 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXCopyFilesBuildPhase section */ 55 | 56 | /* Begin PBXFileReference section */ 57 | 4EF6FE651D586146003863CC /* FormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormViewController.swift; sourceTree = ""; }; 58 | 4EF6FE671D586229003863CC /* FormTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormTableViewCell.swift; sourceTree = ""; }; 59 | 69CEFFC51A9D9F03003B4786 /* GrowingTextViewHandler-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "GrowingTextViewHandler-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 69CEFFC91A9D9F03003B4786 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | 69CEFFCA1A9D9F03003B4786 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 62 | 69CEFFCC1A9D9F03003B4786 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 63 | 69CEFFCF1A9D9F03003B4786 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 64 | 69CEFFD11A9D9F03003B4786 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 65 | 69CEFFD41A9D9F03003B4786 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 66 | 69CEFFDA1A9D9F03003B4786 /* GrowingTextViewHandlerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GrowingTextViewHandlerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | 69CEFFDF1A9D9F03003B4786 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | 69CEFFE01A9D9F03003B4786 /* GrowingTextViewHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrowingTextViewHandlerTests.swift; sourceTree = ""; }; 69 | 69CEFFEB1A9D9FB1003B4786 /* GrowingTextViewHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GrowingTextViewHandler.swift; path = Source/GrowingTextViewHandler.swift; sourceTree = ""; }; 70 | 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GrowingTextViewHandler.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 9A8A4EDB1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GrowingTextViewHandler.h; sourceTree = ""; }; 72 | 9A8A4EDC1DC4A0B000A6D5B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | 9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = ""; }; 74 | /* End PBXFileReference section */ 75 | 76 | /* Begin PBXFrameworksBuildPhase section */ 77 | 69CEFFC21A9D9F03003B4786 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | 9A8A4EE71DC4A24500A6D5B5 /* GrowingTextViewHandler.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 69CEFFD71A9D9F03003B4786 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 9A8A4ED51DC4A0B000A6D5B5 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | 69CEFFBC1A9D9F03003B4786 = { 103 | isa = PBXGroup; 104 | children = ( 105 | 69CEFFC71A9D9F03003B4786 /* GrowingTextViewHandler */, 106 | 69CEFFDD1A9D9F03003B4786 /* GrowingTextViewHandlerTests */, 107 | 9A8A4EDA1DC4A0B000A6D5B5 /* GrowingTextViewHandler */, 108 | 69CEFFC61A9D9F03003B4786 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 69CEFFC61A9D9F03003B4786 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 69CEFFC51A9D9F03003B4786 /* GrowingTextViewHandler-Demo.app */, 116 | 69CEFFDA1A9D9F03003B4786 /* GrowingTextViewHandlerTests.xctest */, 117 | 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */, 118 | ); 119 | name = Products; 120 | sourceTree = ""; 121 | }; 122 | 69CEFFC71A9D9F03003B4786 /* GrowingTextViewHandler */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 69CEFFEA1A9D9F7C003B4786 /* Source */, 126 | 69CEFFCA1A9D9F03003B4786 /* AppDelegate.swift */, 127 | 69CEFFCC1A9D9F03003B4786 /* ViewController.swift */, 128 | 69CEFFCE1A9D9F03003B4786 /* Main.storyboard */, 129 | 69CEFFD11A9D9F03003B4786 /* Images.xcassets */, 130 | 69CEFFD31A9D9F03003B4786 /* LaunchScreen.xib */, 131 | 9A9324631DD35A5B00CB1B99 /* Default-568h@2x.png */, 132 | 69CEFFC81A9D9F03003B4786 /* Supporting Files */, 133 | 4EF6FE671D586229003863CC /* FormTableViewCell.swift */, 134 | 4EF6FE651D586146003863CC /* FormViewController.swift */, 135 | ); 136 | path = GrowingTextViewHandler; 137 | sourceTree = ""; 138 | }; 139 | 69CEFFC81A9D9F03003B4786 /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 69CEFFC91A9D9F03003B4786 /* Info.plist */, 143 | ); 144 | name = "Supporting Files"; 145 | sourceTree = ""; 146 | }; 147 | 69CEFFDD1A9D9F03003B4786 /* GrowingTextViewHandlerTests */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 69CEFFE01A9D9F03003B4786 /* GrowingTextViewHandlerTests.swift */, 151 | 69CEFFDE1A9D9F03003B4786 /* Supporting Files */, 152 | ); 153 | path = GrowingTextViewHandlerTests; 154 | sourceTree = ""; 155 | }; 156 | 69CEFFDE1A9D9F03003B4786 /* Supporting Files */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 69CEFFDF1A9D9F03003B4786 /* Info.plist */, 160 | ); 161 | name = "Supporting Files"; 162 | sourceTree = ""; 163 | }; 164 | 69CEFFEA1A9D9F7C003B4786 /* Source */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | 69CEFFEB1A9D9FB1003B4786 /* GrowingTextViewHandler.swift */, 168 | ); 169 | name = Source; 170 | sourceTree = ""; 171 | }; 172 | 9A8A4EDA1DC4A0B000A6D5B5 /* GrowingTextViewHandler */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | 9A8A4EDB1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h */, 176 | 9A8A4EDC1DC4A0B000A6D5B5 /* Info.plist */, 177 | ); 178 | path = GrowingTextViewHandler; 179 | sourceTree = ""; 180 | }; 181 | /* End PBXGroup section */ 182 | 183 | /* Begin PBXHeadersBuildPhase section */ 184 | 9A8A4ED61DC4A0B000A6D5B5 /* Headers */ = { 185 | isa = PBXHeadersBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | 9A8A4EDD1DC4A0B000A6D5B5 /* GrowingTextViewHandler.h in Headers */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXHeadersBuildPhase section */ 193 | 194 | /* Begin PBXNativeTarget section */ 195 | 69CEFFC41A9D9F03003B4786 /* GrowingTextViewHandler-Demo */ = { 196 | isa = PBXNativeTarget; 197 | buildConfigurationList = 69CEFFE41A9D9F03003B4786 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandler-Demo" */; 198 | buildPhases = ( 199 | 69CEFFC11A9D9F03003B4786 /* Sources */, 200 | 69CEFFC21A9D9F03003B4786 /* Frameworks */, 201 | 69CEFFC31A9D9F03003B4786 /* Resources */, 202 | 9A8A4EE11DC4A0B000A6D5B5 /* Embed Frameworks */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | 9A8A4EDF1DC4A0B000A6D5B5 /* PBXTargetDependency */, 208 | ); 209 | name = "GrowingTextViewHandler-Demo"; 210 | productName = GrowingTextViewHandler; 211 | productReference = 69CEFFC51A9D9F03003B4786 /* GrowingTextViewHandler-Demo.app */; 212 | productType = "com.apple.product-type.application"; 213 | }; 214 | 69CEFFD91A9D9F03003B4786 /* GrowingTextViewHandlerTests */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = 69CEFFE71A9D9F03003B4786 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandlerTests" */; 217 | buildPhases = ( 218 | 69CEFFD61A9D9F03003B4786 /* Sources */, 219 | 69CEFFD71A9D9F03003B4786 /* Frameworks */, 220 | 69CEFFD81A9D9F03003B4786 /* Resources */, 221 | ); 222 | buildRules = ( 223 | ); 224 | dependencies = ( 225 | 69CEFFDC1A9D9F03003B4786 /* PBXTargetDependency */, 226 | ); 227 | name = GrowingTextViewHandlerTests; 228 | productName = GrowingTextViewHandlerTests; 229 | productReference = 69CEFFDA1A9D9F03003B4786 /* GrowingTextViewHandlerTests.xctest */; 230 | productType = "com.apple.product-type.bundle.unit-test"; 231 | }; 232 | 9A8A4ED81DC4A0B000A6D5B5 /* GrowingTextViewHandler */ = { 233 | isa = PBXNativeTarget; 234 | buildConfigurationList = 9A8A4EE31DC4A0B000A6D5B5 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandler" */; 235 | buildPhases = ( 236 | 9A8A4ED41DC4A0B000A6D5B5 /* Sources */, 237 | 9A8A4ED51DC4A0B000A6D5B5 /* Frameworks */, 238 | 9A8A4ED61DC4A0B000A6D5B5 /* Headers */, 239 | 9A8A4ED71DC4A0B000A6D5B5 /* Resources */, 240 | ); 241 | buildRules = ( 242 | ); 243 | dependencies = ( 244 | ); 245 | name = GrowingTextViewHandler; 246 | productName = GrowingTextViewHandler; 247 | productReference = 9A8A4ED91DC4A0B000A6D5B5 /* GrowingTextViewHandler.framework */; 248 | productType = "com.apple.product-type.framework"; 249 | }; 250 | /* End PBXNativeTarget section */ 251 | 252 | /* Begin PBXProject section */ 253 | 69CEFFBD1A9D9F03003B4786 /* Project object */ = { 254 | isa = PBXProject; 255 | attributes = { 256 | LastSwiftMigration = 0700; 257 | LastSwiftUpdateCheck = 0700; 258 | LastUpgradeCheck = 1010; 259 | ORGANIZATIONNAME = hsusmita.com; 260 | TargetAttributes = { 261 | 69CEFFC41A9D9F03003B4786 = { 262 | CreatedOnToolsVersion = 6.1.1; 263 | LastSwiftMigration = 1010; 264 | }; 265 | 69CEFFD91A9D9F03003B4786 = { 266 | CreatedOnToolsVersion = 6.1.1; 267 | LastSwiftMigration = 1010; 268 | TestTargetID = 69CEFFC41A9D9F03003B4786; 269 | }; 270 | 9A8A4ED81DC4A0B000A6D5B5 = { 271 | CreatedOnToolsVersion = 8.1; 272 | LastSwiftMigration = 1010; 273 | ProvisioningStyle = Manual; 274 | }; 275 | }; 276 | }; 277 | buildConfigurationList = 69CEFFC01A9D9F03003B4786 /* Build configuration list for PBXProject "GrowingTextViewHandler" */; 278 | compatibilityVersion = "Xcode 3.2"; 279 | developmentRegion = English; 280 | hasScannedForEncodings = 0; 281 | knownRegions = ( 282 | en, 283 | Base, 284 | ); 285 | mainGroup = 69CEFFBC1A9D9F03003B4786; 286 | productRefGroup = 69CEFFC61A9D9F03003B4786 /* Products */; 287 | projectDirPath = ""; 288 | projectRoot = ""; 289 | targets = ( 290 | 9A8A4ED81DC4A0B000A6D5B5 /* GrowingTextViewHandler */, 291 | 69CEFFC41A9D9F03003B4786 /* GrowingTextViewHandler-Demo */, 292 | 69CEFFD91A9D9F03003B4786 /* GrowingTextViewHandlerTests */, 293 | ); 294 | }; 295 | /* End PBXProject section */ 296 | 297 | /* Begin PBXResourcesBuildPhase section */ 298 | 69CEFFC31A9D9F03003B4786 /* Resources */ = { 299 | isa = PBXResourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 69CEFFD01A9D9F03003B4786 /* Main.storyboard in Resources */, 303 | 9A9324641DD35A5B00CB1B99 /* Default-568h@2x.png in Resources */, 304 | 69CEFFD51A9D9F03003B4786 /* LaunchScreen.xib in Resources */, 305 | 69CEFFD21A9D9F03003B4786 /* Images.xcassets in Resources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | 69CEFFD81A9D9F03003B4786 /* Resources */ = { 310 | isa = PBXResourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | 9A8A4ED71DC4A0B000A6D5B5 /* Resources */ = { 317 | isa = PBXResourcesBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | ); 321 | runOnlyForDeploymentPostprocessing = 0; 322 | }; 323 | /* End PBXResourcesBuildPhase section */ 324 | 325 | /* Begin PBXSourcesBuildPhase section */ 326 | 69CEFFC11A9D9F03003B4786 /* Sources */ = { 327 | isa = PBXSourcesBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | 69CEFFCD1A9D9F03003B4786 /* ViewController.swift in Sources */, 331 | 4EF6FE661D586146003863CC /* FormViewController.swift in Sources */, 332 | 4EF6FE681D586229003863CC /* FormTableViewCell.swift in Sources */, 333 | 69CEFFCB1A9D9F03003B4786 /* AppDelegate.swift in Sources */, 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | }; 337 | 69CEFFD61A9D9F03003B4786 /* Sources */ = { 338 | isa = PBXSourcesBuildPhase; 339 | buildActionMask = 2147483647; 340 | files = ( 341 | 69CEFFE11A9D9F03003B4786 /* GrowingTextViewHandlerTests.swift in Sources */, 342 | ); 343 | runOnlyForDeploymentPostprocessing = 0; 344 | }; 345 | 9A8A4ED41DC4A0B000A6D5B5 /* Sources */ = { 346 | isa = PBXSourcesBuildPhase; 347 | buildActionMask = 2147483647; 348 | files = ( 349 | 9A8A4EE61DC4A0BB00A6D5B5 /* GrowingTextViewHandler.swift in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | /* End PBXSourcesBuildPhase section */ 354 | 355 | /* Begin PBXTargetDependency section */ 356 | 69CEFFDC1A9D9F03003B4786 /* PBXTargetDependency */ = { 357 | isa = PBXTargetDependency; 358 | target = 69CEFFC41A9D9F03003B4786 /* GrowingTextViewHandler-Demo */; 359 | targetProxy = 69CEFFDB1A9D9F03003B4786 /* PBXContainerItemProxy */; 360 | }; 361 | 9A8A4EDF1DC4A0B000A6D5B5 /* PBXTargetDependency */ = { 362 | isa = PBXTargetDependency; 363 | target = 9A8A4ED81DC4A0B000A6D5B5 /* GrowingTextViewHandler */; 364 | targetProxy = 9A8A4EDE1DC4A0B000A6D5B5 /* PBXContainerItemProxy */; 365 | }; 366 | /* End PBXTargetDependency section */ 367 | 368 | /* Begin PBXVariantGroup section */ 369 | 69CEFFCE1A9D9F03003B4786 /* Main.storyboard */ = { 370 | isa = PBXVariantGroup; 371 | children = ( 372 | 69CEFFCF1A9D9F03003B4786 /* Base */, 373 | ); 374 | name = Main.storyboard; 375 | sourceTree = ""; 376 | }; 377 | 69CEFFD31A9D9F03003B4786 /* LaunchScreen.xib */ = { 378 | isa = PBXVariantGroup; 379 | children = ( 380 | 69CEFFD41A9D9F03003B4786 /* Base */, 381 | ); 382 | name = LaunchScreen.xib; 383 | sourceTree = ""; 384 | }; 385 | /* End PBXVariantGroup section */ 386 | 387 | /* Begin XCBuildConfiguration section */ 388 | 69CEFFE21A9D9F03003B4786 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 393 | CLANG_CXX_LIBRARY = "libc++"; 394 | CLANG_ENABLE_MODULES = YES; 395 | CLANG_ENABLE_OBJC_ARC = YES; 396 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_COMMA = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 408 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 411 | CLANG_WARN_STRICT_PROTOTYPES = YES; 412 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 413 | CLANG_WARN_UNREACHABLE_CODE = YES; 414 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 415 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 416 | COPY_PHASE_STRIP = NO; 417 | ENABLE_STRICT_OBJC_MSGSEND = YES; 418 | ENABLE_TESTABILITY = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_DYNAMIC_NO_PIC = NO; 421 | GCC_NO_COMMON_BLOCKS = YES; 422 | GCC_OPTIMIZATION_LEVEL = 0; 423 | GCC_PREPROCESSOR_DEFINITIONS = ( 424 | "DEBUG=1", 425 | "$(inherited)", 426 | ); 427 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 428 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 429 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 430 | GCC_WARN_UNDECLARED_SELECTOR = YES; 431 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 432 | GCC_WARN_UNUSED_FUNCTION = YES; 433 | GCC_WARN_UNUSED_VARIABLE = YES; 434 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 435 | MTL_ENABLE_DEBUG_INFO = YES; 436 | ONLY_ACTIVE_ARCH = YES; 437 | SDKROOT = iphoneos; 438 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 439 | SWIFT_VERSION = 3.0; 440 | }; 441 | name = Debug; 442 | }; 443 | 69CEFFE31A9D9F03003B4786 /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | ALWAYS_SEARCH_USER_PATHS = NO; 447 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 448 | CLANG_CXX_LIBRARY = "libc++"; 449 | CLANG_ENABLE_MODULES = YES; 450 | CLANG_ENABLE_OBJC_ARC = YES; 451 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_COMMA = YES; 454 | CLANG_WARN_CONSTANT_CONVERSION = YES; 455 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 456 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 457 | CLANG_WARN_EMPTY_BODY = YES; 458 | CLANG_WARN_ENUM_CONVERSION = YES; 459 | CLANG_WARN_INFINITE_RECURSION = YES; 460 | CLANG_WARN_INT_CONVERSION = YES; 461 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 462 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 463 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 464 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 465 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 466 | CLANG_WARN_STRICT_PROTOTYPES = YES; 467 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 468 | CLANG_WARN_UNREACHABLE_CODE = YES; 469 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 470 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 471 | COPY_PHASE_STRIP = YES; 472 | ENABLE_NS_ASSERTIONS = NO; 473 | ENABLE_STRICT_OBJC_MSGSEND = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu99; 475 | GCC_NO_COMMON_BLOCKS = YES; 476 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 477 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 478 | GCC_WARN_UNDECLARED_SELECTOR = YES; 479 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 480 | GCC_WARN_UNUSED_FUNCTION = YES; 481 | GCC_WARN_UNUSED_VARIABLE = YES; 482 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 483 | MTL_ENABLE_DEBUG_INFO = NO; 484 | SDKROOT = iphoneos; 485 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 486 | SWIFT_VERSION = 3.0; 487 | VALIDATE_PRODUCT = YES; 488 | }; 489 | name = Release; 490 | }; 491 | 69CEFFE51A9D9F03003B4786 /* Debug */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 495 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 496 | INFOPLIST_FILE = GrowingTextViewHandler/Info.plist; 497 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)"; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | PROVISIONING_PROFILE = ""; 502 | PROVISIONING_PROFILE_SPECIFIER = ""; 503 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 504 | SWIFT_VERSION = 4.2; 505 | }; 506 | name = Debug; 507 | }; 508 | 69CEFFE61A9D9F03003B4786 /* Release */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 512 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 513 | INFOPLIST_FILE = GrowingTextViewHandler/Info.plist; 514 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 515 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 516 | PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)"; 517 | PRODUCT_NAME = "$(TARGET_NAME)"; 518 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 519 | SWIFT_VERSION = 4.2; 520 | }; 521 | name = Release; 522 | }; 523 | 69CEFFE81A9D9F03003B4786 /* Debug */ = { 524 | isa = XCBuildConfiguration; 525 | buildSettings = { 526 | BUNDLE_LOADER = "$(TEST_HOST)"; 527 | FRAMEWORK_SEARCH_PATHS = ( 528 | "$(SDKROOT)/Developer/Library/Frameworks", 529 | "$(inherited)", 530 | ); 531 | GCC_PREPROCESSOR_DEFINITIONS = ( 532 | "DEBUG=1", 533 | "$(inherited)", 534 | ); 535 | INFOPLIST_FILE = GrowingTextViewHandlerTests/Info.plist; 536 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 537 | PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)"; 538 | PRODUCT_NAME = "$(TARGET_NAME)"; 539 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 540 | SWIFT_VERSION = 4.2; 541 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GrowingTextViewHandler-Demo.app/GrowingTextViewHandler-Demo"; 542 | }; 543 | name = Debug; 544 | }; 545 | 69CEFFE91A9D9F03003B4786 /* Release */ = { 546 | isa = XCBuildConfiguration; 547 | buildSettings = { 548 | BUNDLE_LOADER = "$(TEST_HOST)"; 549 | FRAMEWORK_SEARCH_PATHS = ( 550 | "$(SDKROOT)/Developer/Library/Frameworks", 551 | "$(inherited)", 552 | ); 553 | INFOPLIST_FILE = GrowingTextViewHandlerTests/Info.plist; 554 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 555 | PRODUCT_BUNDLE_IDENTIFIER = "com.hsusmita.$(PRODUCT_NAME:rfc1034identifier)"; 556 | PRODUCT_NAME = "$(TARGET_NAME)"; 557 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 558 | SWIFT_VERSION = 4.2; 559 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GrowingTextViewHandler-Demo.app/GrowingTextViewHandler-Demo"; 560 | }; 561 | name = Release; 562 | }; 563 | 9A8A4EE41DC4A0B000A6D5B5 /* Debug */ = { 564 | isa = XCBuildConfiguration; 565 | buildSettings = { 566 | CLANG_ANALYZER_NONNULL = YES; 567 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 568 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 569 | CODE_SIGN_IDENTITY = ""; 570 | CURRENT_PROJECT_VERSION = 1; 571 | DEBUG_INFORMATION_FORMAT = dwarf; 572 | DEFINES_MODULE = YES; 573 | DEVELOPMENT_TEAM = ""; 574 | DYLIB_COMPATIBILITY_VERSION = 1; 575 | DYLIB_CURRENT_VERSION = 1; 576 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 577 | INFOPLIST_FILE = GrowingTextViewHandler/Info.plist; 578 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 579 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 580 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 581 | PRODUCT_BUNDLE_IDENTIFIER = com.GrowingTextViewHandler; 582 | PRODUCT_NAME = "$(TARGET_NAME)"; 583 | SKIP_INSTALL = YES; 584 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 585 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 586 | SWIFT_VERSION = 4.2; 587 | TARGETED_DEVICE_FAMILY = "1,2"; 588 | VERSIONING_SYSTEM = "apple-generic"; 589 | VERSION_INFO_PREFIX = ""; 590 | }; 591 | name = Debug; 592 | }; 593 | 9A8A4EE51DC4A0B000A6D5B5 /* Release */ = { 594 | isa = XCBuildConfiguration; 595 | buildSettings = { 596 | CLANG_ANALYZER_NONNULL = YES; 597 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 598 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 599 | CODE_SIGN_IDENTITY = ""; 600 | COPY_PHASE_STRIP = NO; 601 | CURRENT_PROJECT_VERSION = 1; 602 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 603 | DEFINES_MODULE = YES; 604 | DEVELOPMENT_TEAM = ""; 605 | DYLIB_COMPATIBILITY_VERSION = 1; 606 | DYLIB_CURRENT_VERSION = 1; 607 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 608 | INFOPLIST_FILE = GrowingTextViewHandler/Info.plist; 609 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 610 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 611 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 612 | PRODUCT_BUNDLE_IDENTIFIER = com.GrowingTextViewHandler; 613 | PRODUCT_NAME = "$(TARGET_NAME)"; 614 | SKIP_INSTALL = YES; 615 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 616 | SWIFT_VERSION = 4.2; 617 | TARGETED_DEVICE_FAMILY = "1,2"; 618 | VERSIONING_SYSTEM = "apple-generic"; 619 | VERSION_INFO_PREFIX = ""; 620 | }; 621 | name = Release; 622 | }; 623 | /* End XCBuildConfiguration section */ 624 | 625 | /* Begin XCConfigurationList section */ 626 | 69CEFFC01A9D9F03003B4786 /* Build configuration list for PBXProject "GrowingTextViewHandler" */ = { 627 | isa = XCConfigurationList; 628 | buildConfigurations = ( 629 | 69CEFFE21A9D9F03003B4786 /* Debug */, 630 | 69CEFFE31A9D9F03003B4786 /* Release */, 631 | ); 632 | defaultConfigurationIsVisible = 0; 633 | defaultConfigurationName = Release; 634 | }; 635 | 69CEFFE41A9D9F03003B4786 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandler-Demo" */ = { 636 | isa = XCConfigurationList; 637 | buildConfigurations = ( 638 | 69CEFFE51A9D9F03003B4786 /* Debug */, 639 | 69CEFFE61A9D9F03003B4786 /* Release */, 640 | ); 641 | defaultConfigurationIsVisible = 0; 642 | defaultConfigurationName = Release; 643 | }; 644 | 69CEFFE71A9D9F03003B4786 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandlerTests" */ = { 645 | isa = XCConfigurationList; 646 | buildConfigurations = ( 647 | 69CEFFE81A9D9F03003B4786 /* Debug */, 648 | 69CEFFE91A9D9F03003B4786 /* Release */, 649 | ); 650 | defaultConfigurationIsVisible = 0; 651 | defaultConfigurationName = Release; 652 | }; 653 | 9A8A4EE31DC4A0B000A6D5B5 /* Build configuration list for PBXNativeTarget "GrowingTextViewHandler" */ = { 654 | isa = XCConfigurationList; 655 | buildConfigurations = ( 656 | 9A8A4EE41DC4A0B000A6D5B5 /* Debug */, 657 | 9A8A4EE51DC4A0B000A6D5B5 /* Release */, 658 | ); 659 | defaultConfigurationIsVisible = 0; 660 | defaultConfigurationName = Release; 661 | }; 662 | /* End XCConfigurationList section */ 663 | }; 664 | rootObject = 69CEFFBD1A9D9F03003B4786 /* Project object */; 665 | } 666 | -------------------------------------------------------------------------------- /GrowingTextViewHandler.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GrowingTextViewHandler.xcodeproj/xcshareddata/xcschemes/GrowingTextViewHandler.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GrowingTextViewHandler 4 | // 5 | // Created by hsusmita on 25/02/15. 6 | // Copyright (c) 2015 hsusmita.com. 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 throttle down OpenGL ES frame rates. 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 inactive 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 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/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 | 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 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 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 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/FormTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FormTableViewCell.swift 3 | // GrowingTextViewHandler 4 | // 5 | // Created by Susmita Horrow on 08/08/16. 6 | // Copyright © 2016 hsusmita.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GrowingTextViewHandler 11 | 12 | protocol FormTableViewCellDelegate { 13 | func formTableViewCell(_ formTableViewCell: FormTableViewCell, shouldChangeHeight height: CGFloat) 14 | } 15 | 16 | class FormTableViewCell: UITableViewCell { 17 | @IBOutlet weak var textView: UITextView! 18 | fileprivate var handler: GrowingTextViewHandler? 19 | var delegate: FormTableViewCellDelegate? 20 | @IBOutlet weak var heightConstraint: NSLayoutConstraint! 21 | 22 | override func awakeFromNib() { 23 | super.awakeFromNib() 24 | handler = GrowingTextViewHandler(textView: self.textView, heightConstraint: self.heightConstraint) 25 | handler?.minimumNumberOfLines = 2 26 | handler?.maximumNumberOfLines = 6 27 | handler?.setText("", animated: false) 28 | // handler?.setText("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.", animated: false) 29 | } 30 | 31 | override func setSelected(_ selected: Bool, animated: Bool) { 32 | super.setSelected(selected, animated: animated) 33 | // Configure the view for the selected state 34 | } 35 | 36 | func textViewDidChange(_ textView: UITextView) { 37 | let oldFrame = textView.frame 38 | self.handler?.resizeTextView(true) 39 | let currentFrame = textView.frame 40 | if oldFrame.height != currentFrame.height { 41 | delegate?.formTableViewCell(self, shouldChangeHeight: textView.frame.height) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/FormViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FormViewController.swift 3 | // GrowingTextViewHandler 4 | // 5 | // Created by Susmita Horrow on 08/08/16. 6 | // Copyright © 2016 hsusmita.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FormViewController: UIViewController { 12 | @IBOutlet weak var tableView: UITableView! 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | tableView.estimatedRowHeight = 50.0 17 | tableView.rowHeight = UITableView.automaticDimension 18 | } 19 | } 20 | 21 | extension FormViewController: UITableViewDataSource { 22 | func numberOfSections(in tableView: UITableView) -> Int { 23 | return 1 24 | } 25 | 26 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 27 | return 1 28 | } 29 | 30 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 31 | let cell = tableView.dequeueReusableCell(withIdentifier: "FormTableViewCellIdentifier") as? FormTableViewCell 32 | cell?.delegate = self 33 | return cell! 34 | } 35 | } 36 | 37 | extension FormViewController: FormTableViewCellDelegate { 38 | func formTableViewCell(_ formTableViewCell: FormTableViewCell, shouldChangeHeight height: CGFloat) { 39 | tableView.beginUpdates() 40 | tableView.endUpdates() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/GrowingTextViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // GrowingTextViewHandler.h 3 | // GrowingTextViewHandler 4 | // 5 | // Created by Anders Friis on 29/10/2016. 6 | // Copyright © 2016 hsusmita.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for GrowingTextViewHandler. 12 | FOUNDATION_EXPORT double GrowingTextViewHandlerVersionNumber; 13 | 14 | //! Project version string for GrowingTextViewHandler. 15 | FOUNDATION_EXPORT const unsigned char GrowingTextViewHandlerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/Images.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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /GrowingTextViewHandler/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | UIMainStoryboardFile 24 | Main 25 | 26 | 27 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/Source/GrowingTextViewHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GrowingTextViewHandler.swift 3 | // GrowingTextViewHandler 4 | // 5 | // Created by hsusmita on 25/02/15. 6 | // Copyright (c) 2015 hsusmita.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | open class GrowingTextViewHandler: NSObject { 12 | open var growingTextView : UITextView! 13 | open var heightChangeAnimationDuration = 0.5 14 | open var maximumNumberOfLines = Int.max { 15 | didSet { 16 | updateInitialHeightAndResize() 17 | } 18 | } 19 | open var minimumNumberOfLines = 1 { 20 | didSet { 21 | updateInitialHeightAndResize() 22 | } 23 | } 24 | 25 | private var textViewHeightConstraint: NSLayoutConstraint? 26 | 27 | /** 28 | The minumum height of the textView 29 | */ 30 | private var initialHeight: CGFloat = 0.0 31 | 32 | /** 33 | The maximum height of the textView upto which it should grow and start scrolling 34 | */ 35 | private var maximumHeight: CGFloat = 0.0 36 | 37 | /** 38 | This denotes the line height of single line of characters. This value depends on the font size. 39 | */ 40 | private var caretHeight: CGFloat { 41 | if let selectedTextRange = growingTextView.selectedTextRange { 42 | return growingTextView.caretRect(for: selectedTextRange.end).size.height 43 | } else { 44 | return 0.0 45 | } 46 | } 47 | /** 48 | This gives the total height of the textView based on the text present in it 49 | */ 50 | private var currentHeight: CGFloat { 51 | guard let textViewFont = growingTextView.font else { 52 | return 0.0 53 | } 54 | let width = growingTextView.bounds.size.width - 2.0 * growingTextView.textContainer.lineFragmentPadding 55 | let boundingRect = growingTextView.text.boundingRect( 56 | with: CGSize(width: width, height: CGFloat.greatestFiniteMagnitude), 57 | options: [.usesLineFragmentOrigin, .usesFontLeading], 58 | attributes: [NSAttributedString.Key.font: textViewFont], context: nil) 59 | let heightByBoundingRect = boundingRect.height + textViewFont.lineHeight 60 | return max(heightByBoundingRect, growingTextView.contentSize.height) 61 | } 62 | 63 | /** 64 | This gives the number of lines based on the text present in it 65 | */ 66 | private var currentNumberOfLines: Int { 67 | let totalHeight = currentHeight + growingTextView.textContainerInset.top + growingTextView.textContainerInset.bottom 68 | return Int(totalHeight/caretHeight) - 1 69 | } 70 | 71 | // MARK:- Public methods 72 | 73 | /** 74 | Initializes and returns an instance GrowingTextViewHandler 75 | 76 | - parameters: 77 | - textView: The textView which is to be resized as the text changes 78 | - heightConstraint: The heightConstraint of the textView, which is altered based on size of the content of the textView 79 | */ 80 | public init(textView: UITextView, heightConstraint: NSLayoutConstraint) { 81 | super.init() 82 | growingTextView = textView 83 | textViewHeightConstraint = heightConstraint 84 | initialHeight = heightConstraint.constant 85 | updateInitialHeightAndResize() 86 | } 87 | /** 88 | Resizes the text view 89 | This method needs to be called in the method **textViewDidChange(textView: UITextView)** 90 | 91 | - parameters: 92 | - animated: If set as true, the height change will be animated 93 | */ 94 | open func resizeTextView(_ animated: Bool) { 95 | let textViewNumberOfLines = currentNumberOfLines 96 | var verticalAlignmentConstant: CGFloat = 0.0 97 | if textViewNumberOfLines <= minimumNumberOfLines { 98 | verticalAlignmentConstant = initialHeight 99 | } else if (textViewNumberOfLines > minimumNumberOfLines) && (textViewNumberOfLines <= maximumNumberOfLines) { 100 | verticalAlignmentConstant = max(currentHeight, initialHeight) 101 | } else if textViewNumberOfLines > maximumNumberOfLines { 102 | verticalAlignmentConstant = maximumHeight 103 | } 104 | if let heightConstraint = textViewHeightConstraint , heightConstraint.constant != verticalAlignmentConstant { 105 | updateVerticalAlignmentWithHeight(verticalAlignmentConstant, animated: animated) 106 | } 107 | if textViewNumberOfLines <= maximumNumberOfLines { 108 | growingTextView.setContentOffset(CGPoint.zero, animated: true) 109 | } 110 | } 111 | 112 | /** 113 | This method sets the text of the textView as well as updates the height of textView based on the content size 114 | 115 | - parameters: 116 | - animated: If set as true, the height change will be animated 117 | */ 118 | 119 | open func setText(_ text: String, animated: Bool) { 120 | self.growingTextView.text = text 121 | if text.isEmpty { 122 | updateVerticalAlignmentWithHeight(self.initialHeight, animated: animated) 123 | } else { 124 | resizeTextView(animated) 125 | } 126 | } 127 | 128 | // MARK: - Private Helpers 129 | 130 | /** 131 | This method initialzes the variables intialHeight and maximum height and performs initial resize 132 | */ 133 | 134 | private func updateInitialHeightAndResize() { 135 | initialHeight = estimatedInitialHeight() 136 | maximumHeight = estimatedMaximumHeight() 137 | resizeTextView(false) 138 | } 139 | /** 140 | This method gives the estimated value for the initial height of the textView. 141 | 142 | - returns: 143 | The method caluclates the height based on minimumNumberOfLines and caretHeight, compares with current height of textView 144 | and returns the maximum of two. 145 | */ 146 | 147 | private func estimatedInitialHeight() -> CGFloat { 148 | let totalHeight = caretHeight * CGFloat(minimumNumberOfLines) + growingTextView.textContainerInset.top 149 | + growingTextView.textContainerInset.bottom 150 | return fmax(totalHeight, initialHeight) 151 | } 152 | 153 | /** 154 | This method gives the estimated value for the maximum height upto which the textView can grow 155 | 156 | maximumNumberOfLines and caretHeight are the factors which determine the maximum height of the textView 157 | */ 158 | 159 | private func estimatedMaximumHeight() -> CGFloat { 160 | let totalHeight = caretHeight * CGFloat(maximumNumberOfLines) + growingTextView.textContainerInset.top 161 | + growingTextView.textContainerInset.bottom 162 | return totalHeight 163 | } 164 | 165 | /** 166 | This method updated the height constraint of the textView 167 | 168 | - parameters: 169 | - height: The desired height of the textView 170 | - animated: If set as true, the height change will be animated 171 | */ 172 | 173 | private func updateVerticalAlignmentWithHeight(_ height: CGFloat, animated: Bool) { 174 | guard let heightConstraint = textViewHeightConstraint else { 175 | return 176 | } 177 | heightConstraint.constant = height 178 | if (animated == true) { 179 | UIView.animate(withDuration: heightChangeAnimationDuration, animations: { 180 | self.growingTextView.superview?.layoutIfNeeded() 181 | }, completion: nil) 182 | } else { 183 | growingTextView.superview?.layoutIfNeeded() 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /GrowingTextViewHandler/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // GrowingTextViewHandler 4 | // 5 | // Created by hsusmita on 25/02/15. 6 | // Copyright (c) 2015 hsusmita.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GrowingTextViewHandler 11 | 12 | class ViewController: UIViewController,UITextViewDelegate { 13 | 14 | @IBOutlet weak var textView: UITextView! 15 | @IBOutlet weak var heightConstraint: NSLayoutConstraint! 16 | var handler: GrowingTextViewHandler? 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | handler = GrowingTextViewHandler(textView: self.textView, heightConstraint: self.heightConstraint) 21 | handler?.minimumNumberOfLines = 2 22 | handler?.maximumNumberOfLines = 6 23 | handler?.setText("", animated: false) 24 | } 25 | 26 | override func viewDidLayoutSubviews() { 27 | super.viewDidLayoutSubviews() 28 | } 29 | 30 | func textViewDidChange(_ textView: UITextView) { 31 | self.handler?.resizeTextView(true) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /GrowingTextViewHandlerTests/GrowingTextViewHandlerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GrowingTextViewHandlerTests.swift 3 | // GrowingTextViewHandlerTests 4 | // 5 | // Created by hsusmita on 25/02/15. 6 | // Copyright (c) 2015 hsusmita.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class GrowingTextViewHandlerTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /GrowingTextViewHandlerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GrowingTextViewHandler 2 | An NSObject subclass to handle resizing of UITextView as the user types in. The textview resizes as long as the number of lines lies between specified minimum and maximum number of lines. 3 | These are the public properties which can be set from the client code. 4 | * animationDuration : Default 0.5 5 | * maximumNumberOfLines : Default INT_MAX 6 | * minimumNumberOfLines : Default 1 7 | 8 | 9 | #Installation 10 | 11 | Add following lines in your pod file for Swift 4 12 | ``` 13 | pod 'GrowingTextViewHandler-Swift', '1.2' 14 | ``` 15 | For older versions, use 16 | 17 | ``` 18 | pod 'GrowingTextViewHandler-Swift', '1.0.3' 19 | ``` 20 | 21 | #Usage 22 | 23 | First create an instance of GrowingTextViewHandler. It takes an UITextView and its height constraint as arguments. You can specify the maximum and minimum number of lines. Then in the method "textViewDidChange" call the method resizeTextView 24 | ``` 25 | var handler:GrowingTextViewHandler? 26 | @IBOutlet weak var aTextView: UITextView! 27 | @IBOutlet weak var heightConstraint: NSLayoutConstraint! 28 | override func viewDidLoad() { 29 | super.viewDidLoad() 30 | self.handler? = GrowingTextViewHandler(textView: self.aTextView, heightConstraint: heightConstraint) 31 | self.handler?.minimumNumberOfLines = 2 32 | self.handler?.maximumNumberOfLines = 6 33 | } 34 | 35 | func textViewDidChange(textView: UITextView) { 36 | self.handler?.resizeTextView(animated:true) 37 | } 38 | 39 | ``` 40 | 41 | However when you set text programmatically, **textViewDidChange(textView: UITextView)** does not get called. For this case you can resize UITextView as follows: 42 | ``` 43 | self.handler?.setText("Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", animated: true) 44 | 45 | ``` 46 | # Screenshots 47 | 48 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) [2015] [Susmita Horrow] 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 | --------------------------------------------------------------------------------