├── .gitignore ├── Gif └── GrowingTextViewExample.gif ├── GrowingTextView.xcodeproj ├── project.pbxproj ├── xcshareddata │ └── xcschemes │ │ └── GrowingTextView.xcscheme └── xcuserdata │ └── hongxin.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── GrowingTextView.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── GrowingTextView ├── GrowingInternalTextView.swift ├── GrowingTextView.swift ├── Protocol.swift └── Supporting Files │ └── Info.plist ├── GrowingTextViewExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── hongxin.xcuserdatad │ └── xcschemes │ ├── GrowingTextViewExample.xcscheme │ └── xcschememanagement.plist ├── GrowingTextViewExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── attachmentsIcon.imageset │ │ ├── Contents.json │ │ └── attachmentsIcon.pdf │ ├── emojiIcon.imageset │ │ ├── Contents.json │ │ └── emojiIcon.pdf │ └── voiceIcon.imageset │ │ ├── Contents.json │ │ └── voiceIcon.pdf ├── Base.lproj │ └── Main.storyboard ├── ExampleViewController.swift ├── Info.plist ├── LeftMessageCell.swift ├── MessageLabel.swift └── RightMessageCell.swift ├── LICENSE.md ├── README.md └── TBGrowingTextView.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | Carthage/ 9 | 10 | ## Various settings 11 | *.pbxuser 12 | !default.pbxuser 13 | *.mode1v3 14 | !default.mode1v3 15 | *.mode2v3 16 | !default.mode2v3 17 | *.perspectivev3 18 | !default.perspectivev3 19 | xcuserdata/ 20 | 21 | ## Other 22 | *.moved-aside 23 | *.xccheckout 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | *.dSYM 31 | 32 | ## Playgrounds 33 | timeline.xctimeline 34 | playground.xcworkspace 35 | 36 | # Swift Package Manager 37 | # 38 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 39 | # Packages/ 40 | # Package.pins 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /Gif/GrowingTextViewExample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba-archive/GrowingTextView/4917f8867494386c7143fc901dd051bbb30bfe62/Gif/GrowingTextViewExample.gif -------------------------------------------------------------------------------- /GrowingTextView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D3913F381C72EE4000AB3B29 /* GrowingTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3913F371C72EE4000AB3B29 /* GrowingTextView.swift */; }; 11 | D3DA9AD41C72F3C600D7B4F8 /* Protocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DA9AD31C72F3C600D7B4F8 /* Protocol.swift */; }; 12 | D3DA9AD61C72F78000D7B4F8 /* GrowingInternalTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DA9AD51C72F78000D7B4F8 /* GrowingInternalTextView.swift */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXFileReference section */ 16 | D3913F291C72EC8900AB3B29 /* GrowingTextView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GrowingTextView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 17 | D3913F351C72ED5700AB3B29 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = "GrowingTextView/Supporting Files/Info.plist"; sourceTree = ""; }; 18 | D3913F371C72EE4000AB3B29 /* GrowingTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GrowingTextView.swift; sourceTree = ""; }; 19 | D3DA9AD31C72F3C600D7B4F8 /* Protocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Protocol.swift; sourceTree = ""; }; 20 | D3DA9AD51C72F78000D7B4F8 /* GrowingInternalTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GrowingInternalTextView.swift; sourceTree = ""; }; 21 | /* End PBXFileReference section */ 22 | 23 | /* Begin PBXFrameworksBuildPhase section */ 24 | D3913F251C72EC8900AB3B29 /* Frameworks */ = { 25 | isa = PBXFrameworksBuildPhase; 26 | buildActionMask = 2147483647; 27 | files = ( 28 | ); 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXFrameworksBuildPhase section */ 32 | 33 | /* Begin PBXGroup section */ 34 | D3913F1F1C72EC8900AB3B29 = { 35 | isa = PBXGroup; 36 | children = ( 37 | D3913F2B1C72EC8900AB3B29 /* GrowingTextView */, 38 | D3913F341C72ED4300AB3B29 /* Supporting Files */, 39 | D3913F2A1C72EC8900AB3B29 /* Products */, 40 | ); 41 | sourceTree = ""; 42 | }; 43 | D3913F2A1C72EC8900AB3B29 /* Products */ = { 44 | isa = PBXGroup; 45 | children = ( 46 | D3913F291C72EC8900AB3B29 /* GrowingTextView.framework */, 47 | ); 48 | name = Products; 49 | sourceTree = ""; 50 | }; 51 | D3913F2B1C72EC8900AB3B29 /* GrowingTextView */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | D3DA9AD31C72F3C600D7B4F8 /* Protocol.swift */, 55 | D3913F371C72EE4000AB3B29 /* GrowingTextView.swift */, 56 | D3DA9AD51C72F78000D7B4F8 /* GrowingInternalTextView.swift */, 57 | ); 58 | path = GrowingTextView; 59 | sourceTree = ""; 60 | }; 61 | D3913F341C72ED4300AB3B29 /* Supporting Files */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | D3913F351C72ED5700AB3B29 /* Info.plist */, 65 | ); 66 | name = "Supporting Files"; 67 | sourceTree = ""; 68 | }; 69 | /* End PBXGroup section */ 70 | 71 | /* Begin PBXHeadersBuildPhase section */ 72 | D3913F261C72EC8900AB3B29 /* Headers */ = { 73 | isa = PBXHeadersBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXHeadersBuildPhase section */ 80 | 81 | /* Begin PBXNativeTarget section */ 82 | D3913F281C72EC8900AB3B29 /* GrowingTextView */ = { 83 | isa = PBXNativeTarget; 84 | buildConfigurationList = D3913F311C72EC8900AB3B29 /* Build configuration list for PBXNativeTarget "GrowingTextView" */; 85 | buildPhases = ( 86 | D3913F241C72EC8900AB3B29 /* Sources */, 87 | D3913F251C72EC8900AB3B29 /* Frameworks */, 88 | D3913F261C72EC8900AB3B29 /* Headers */, 89 | D3913F271C72EC8900AB3B29 /* Resources */, 90 | ); 91 | buildRules = ( 92 | ); 93 | dependencies = ( 94 | ); 95 | name = GrowingTextView; 96 | productName = GrowingTextView; 97 | productReference = D3913F291C72EC8900AB3B29 /* GrowingTextView.framework */; 98 | productType = "com.apple.product-type.framework"; 99 | }; 100 | /* End PBXNativeTarget section */ 101 | 102 | /* Begin PBXProject section */ 103 | D3913F201C72EC8900AB3B29 /* Project object */ = { 104 | isa = PBXProject; 105 | attributes = { 106 | LastUpgradeCheck = 1020; 107 | ORGANIZATIONNAME = Teambition; 108 | TargetAttributes = { 109 | D3913F281C72EC8900AB3B29 = { 110 | CreatedOnToolsVersion = 7.2.1; 111 | LastSwiftMigration = 1020; 112 | }; 113 | }; 114 | }; 115 | buildConfigurationList = D3913F231C72EC8900AB3B29 /* Build configuration list for PBXProject "GrowingTextView" */; 116 | compatibilityVersion = "Xcode 3.2"; 117 | developmentRegion = en; 118 | hasScannedForEncodings = 0; 119 | knownRegions = ( 120 | en, 121 | Base, 122 | ); 123 | mainGroup = D3913F1F1C72EC8900AB3B29; 124 | productRefGroup = D3913F2A1C72EC8900AB3B29 /* Products */; 125 | projectDirPath = ""; 126 | projectRoot = ""; 127 | targets = ( 128 | D3913F281C72EC8900AB3B29 /* GrowingTextView */, 129 | ); 130 | }; 131 | /* End PBXProject section */ 132 | 133 | /* Begin PBXResourcesBuildPhase section */ 134 | D3913F271C72EC8900AB3B29 /* Resources */ = { 135 | isa = PBXResourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | ); 139 | runOnlyForDeploymentPostprocessing = 0; 140 | }; 141 | /* End PBXResourcesBuildPhase section */ 142 | 143 | /* Begin PBXSourcesBuildPhase section */ 144 | D3913F241C72EC8900AB3B29 /* Sources */ = { 145 | isa = PBXSourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | D3DA9AD61C72F78000D7B4F8 /* GrowingInternalTextView.swift in Sources */, 149 | D3913F381C72EE4000AB3B29 /* GrowingTextView.swift in Sources */, 150 | D3DA9AD41C72F3C600D7B4F8 /* Protocol.swift in Sources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXSourcesBuildPhase section */ 155 | 156 | /* Begin XCBuildConfiguration section */ 157 | D3913F2F1C72EC8900AB3B29 /* Debug */ = { 158 | isa = XCBuildConfiguration; 159 | buildSettings = { 160 | ALWAYS_SEARCH_USER_PATHS = NO; 161 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 162 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 163 | CLANG_CXX_LIBRARY = "libc++"; 164 | CLANG_ENABLE_MODULES = YES; 165 | CLANG_ENABLE_OBJC_ARC = YES; 166 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 167 | CLANG_WARN_BOOL_CONVERSION = YES; 168 | CLANG_WARN_COMMA = YES; 169 | CLANG_WARN_CONSTANT_CONVERSION = YES; 170 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 171 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 172 | CLANG_WARN_EMPTY_BODY = YES; 173 | CLANG_WARN_ENUM_CONVERSION = YES; 174 | CLANG_WARN_INFINITE_RECURSION = YES; 175 | CLANG_WARN_INT_CONVERSION = YES; 176 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 177 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 178 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 179 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 180 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 181 | CLANG_WARN_STRICT_PROTOTYPES = YES; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 186 | COPY_PHASE_STRIP = NO; 187 | CURRENT_PROJECT_VERSION = 1; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | TARGETED_DEVICE_FAMILY = "1,2"; 211 | VERSIONING_SYSTEM = "apple-generic"; 212 | VERSION_INFO_PREFIX = ""; 213 | }; 214 | name = Debug; 215 | }; 216 | D3913F301C72EC8900AB3B29 /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 222 | CLANG_CXX_LIBRARY = "libc++"; 223 | CLANG_ENABLE_MODULES = YES; 224 | CLANG_ENABLE_OBJC_ARC = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INFINITE_RECURSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 236 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 237 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 238 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 239 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 240 | CLANG_WARN_STRICT_PROTOTYPES = YES; 241 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 242 | CLANG_WARN_UNREACHABLE_CODE = YES; 243 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 244 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 245 | COPY_PHASE_STRIP = NO; 246 | CURRENT_PROJECT_VERSION = 1; 247 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 248 | ENABLE_NS_ASSERTIONS = NO; 249 | ENABLE_STRICT_OBJC_MSGSEND = YES; 250 | GCC_C_LANGUAGE_STANDARD = gnu99; 251 | GCC_NO_COMMON_BLOCKS = YES; 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 259 | MTL_ENABLE_DEBUG_INFO = NO; 260 | SDKROOT = iphoneos; 261 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 262 | TARGETED_DEVICE_FAMILY = "1,2"; 263 | VALIDATE_PRODUCT = YES; 264 | VERSIONING_SYSTEM = "apple-generic"; 265 | VERSION_INFO_PREFIX = ""; 266 | }; 267 | name = Release; 268 | }; 269 | D3913F321C72EC8900AB3B29 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | CLANG_ENABLE_MODULES = YES; 273 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 274 | DEFINES_MODULE = YES; 275 | DYLIB_COMPATIBILITY_VERSION = 1; 276 | DYLIB_CURRENT_VERSION = 1; 277 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 278 | INFOPLIST_FILE = "$(SRCROOT)/GrowingTextView/Supporting Files/Info.plist"; 279 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 280 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 281 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.GrowingTextView; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | SKIP_INSTALL = YES; 284 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 285 | SWIFT_VERSION = 5.0; 286 | }; 287 | name = Debug; 288 | }; 289 | D3913F331C72EC8900AB3B29 /* Release */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | CLANG_ENABLE_MODULES = YES; 293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 294 | DEFINES_MODULE = YES; 295 | DYLIB_COMPATIBILITY_VERSION = 1; 296 | DYLIB_CURRENT_VERSION = 1; 297 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 298 | INFOPLIST_FILE = "$(SRCROOT)/GrowingTextView/Supporting Files/Info.plist"; 299 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.GrowingTextView; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | SKIP_INSTALL = YES; 304 | SWIFT_VERSION = 5.0; 305 | }; 306 | name = Release; 307 | }; 308 | /* End XCBuildConfiguration section */ 309 | 310 | /* Begin XCConfigurationList section */ 311 | D3913F231C72EC8900AB3B29 /* Build configuration list for PBXProject "GrowingTextView" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | D3913F2F1C72EC8900AB3B29 /* Debug */, 315 | D3913F301C72EC8900AB3B29 /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | D3913F311C72EC8900AB3B29 /* Build configuration list for PBXNativeTarget "GrowingTextView" */ = { 321 | isa = XCConfigurationList; 322 | buildConfigurations = ( 323 | D3913F321C72EC8900AB3B29 /* Debug */, 324 | D3913F331C72EC8900AB3B29 /* Release */, 325 | ); 326 | defaultConfigurationIsVisible = 0; 327 | defaultConfigurationName = Release; 328 | }; 329 | /* End XCConfigurationList section */ 330 | }; 331 | rootObject = D3913F201C72EC8900AB3B29 /* Project object */; 332 | } 333 | -------------------------------------------------------------------------------- /GrowingTextView.xcodeproj/xcshareddata/xcschemes/GrowingTextView.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 | -------------------------------------------------------------------------------- /GrowingTextView.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | GrowingTextView.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D3913F281C72EC8900AB3B29 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /GrowingTextView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /GrowingTextView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GrowingTextView/GrowingInternalTextView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GrowingInternalTextView.swift 3 | // GrowingTextView 4 | // 5 | // Created by Xin Hong on 16/2/16. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | internal class GrowingInternalTextView: UITextView, NSCopying { 12 | var placeholder: NSAttributedString? { 13 | didSet { 14 | setNeedsDisplay() 15 | } 16 | } 17 | var shouldDisplayPlaceholder = true { 18 | didSet { 19 | if shouldDisplayPlaceholder != oldValue { 20 | setNeedsDisplay() 21 | } 22 | } 23 | } 24 | var isCaretHidden = false 25 | 26 | fileprivate var isScrollEnabledTemp = false 27 | 28 | override var text: String! { 29 | willSet { 30 | // If one of GrowingTextView's superviews is a scrollView, and self.scrollEnabled is false, setting the text programatically will cause UIKit to search upwards until it finds a scrollView with scrollEnabled true, then scroll it erratically. Setting scrollEnabled temporarily to true prevents this. 31 | isScrollEnabledTemp = isScrollEnabled 32 | isScrollEnabled = true 33 | } 34 | didSet { 35 | isScrollEnabled = isScrollEnabledTemp 36 | } 37 | } 38 | 39 | override func draw(_ rect: CGRect) { 40 | super.draw(rect) 41 | guard let placeholder = placeholder, shouldDisplayPlaceholder else { 42 | return 43 | } 44 | let placeholderSize = sizeForAttributedString(placeholder) 45 | let xPosition: CGFloat = textContainer.lineFragmentPadding + textContainerInset.left 46 | let yPosition: CGFloat = (textContainerInset.top - textContainerInset.bottom) / 2 47 | let rect = CGRect(origin: CGPoint(x: xPosition, y: yPosition), size: placeholderSize) 48 | placeholder.draw(in: rect) 49 | } 50 | 51 | override func caretRect(for position: UITextPosition) -> CGRect { 52 | if isCaretHidden { 53 | return .zero 54 | } 55 | return super.caretRect(for: position) 56 | } 57 | 58 | func copy(with zone: NSZone?) -> Any { 59 | let textView = GrowingInternalTextView(frame: frame) 60 | textView.isScrollEnabled = isScrollEnabled 61 | textView.shouldDisplayPlaceholder = shouldDisplayPlaceholder 62 | textView.isCaretHidden = isCaretHidden 63 | textView.placeholder = placeholder 64 | textView.text = text 65 | textView.font = font 66 | textView.textColor = textColor 67 | textView.textAlignment = textAlignment 68 | textView.isEditable = isEditable 69 | textView.selectedRange = selectedRange 70 | textView.dataDetectorTypes = dataDetectorTypes 71 | textView.returnKeyType = returnKeyType 72 | textView.keyboardType = keyboardType 73 | textView.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically 74 | 75 | textView.textContainerInset = textContainerInset 76 | textView.textContainer.lineFragmentPadding = textContainer.lineFragmentPadding 77 | textView.showsHorizontalScrollIndicator = showsHorizontalScrollIndicator 78 | textView.contentInset = contentInset 79 | textView.contentMode = contentMode 80 | 81 | return textView 82 | } 83 | 84 | fileprivate func sizeForAttributedString(_ attributedString: NSAttributedString) -> CGSize { 85 | let size = attributedString.size() 86 | return CGRect(origin: .zero, size: size).integral.size 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /GrowingTextView/GrowingTextView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GrowingTextView.swift 3 | // GrowingTextView 4 | // 5 | // Created by Xin Hong on 16/2/16. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | open class GrowingTextView: UIView { 12 | // MARK: - Public properties 13 | open weak var delegate: GrowingTextViewDelegate? 14 | 15 | open var internalTextView: UITextView { 16 | return textView 17 | } 18 | open var maxNumberOfLines: Int? { 19 | willSet { 20 | if let newValue = newValue { 21 | assert(newValue >= 0, "MaxNumberOfLines of growingTextView must be no less than 0.") 22 | } 23 | } 24 | didSet { 25 | updateMaxHeight() 26 | } 27 | } 28 | open var minNumberOfLines: Int? { 29 | willSet { 30 | if let newValue = newValue { 31 | assert(newValue >= 0, "MinNumberOfLines of growingTextView must be no less than 0.") 32 | } 33 | } 34 | didSet { 35 | updateMinHeight() 36 | } 37 | } 38 | open var maxHeight: CGFloat? { 39 | willSet { 40 | if let newValue = newValue { 41 | assert(newValue >= 0, "MaxHeight of growingTextView must be no less than 0.") 42 | } 43 | } 44 | } 45 | open var minHeight: CGFloat = 0 { 46 | willSet { 47 | assert(newValue >= 0, "MinHeight of growingTextView must be no less than 0.") 48 | } 49 | } 50 | /// A Boolean value that determines whether growing animations are enabled. 51 | /// 52 | /// The default value of this property is true. 53 | open var isGrowingAnimationEnabled = true 54 | /// The time duration of text view's growing animation. 55 | /// 56 | /// The default value of this property is 0.1. 57 | open var animationDuration: TimeInterval = 0.1 58 | /// The inset of the text view. 59 | /// 60 | /// The default value of this property is (top: 8, left: 5, bottom: 8, right: 5). 61 | open var contentInset = UIEdgeInsets(top: 8, left: 5, bottom: 8, right: 5) { 62 | didSet { 63 | updateTextViewFrame() 64 | updateMaxHeight() 65 | updateMinHeight() 66 | } 67 | } 68 | /// A Boolean value that determines whether scrolling is enabled. 69 | /// 70 | /// If the value of this property is true, scrolling is enabled, and if it is false, scrolling is disabled. The default is false. 71 | open var isScrollEnabled = false { 72 | didSet { 73 | textView.isScrollEnabled = isScrollEnabled 74 | } 75 | } 76 | /// A Boolean value that determines whether to display a placeholder when the text is empty. 77 | /// 78 | /// The default value of this property is true. 79 | open var isPlaceholderEnabled = true { 80 | didSet { 81 | textView.shouldDisplayPlaceholder = textView.text.isEmpty && isPlaceholderEnabled 82 | } 83 | } 84 | /// An attributed string that displays when there is no other text in the text view. 85 | open var placeholder: NSAttributedString? { 86 | set { 87 | textView.placeholder = newValue 88 | } 89 | get { 90 | return textView.placeholder 91 | } 92 | } 93 | /// A Boolean value that determines whether to display the caret. 94 | /// 95 | /// The default value of this property is false. 96 | open var isCaretHidden = false { 97 | didSet { 98 | textView.isCaretHidden = isCaretHidden 99 | } 100 | } 101 | 102 | // MARK: - UITextView properties 103 | /// The text displayed by the text view. 104 | open var text: String? { 105 | set { 106 | textView.text = newValue 107 | updateHeight() 108 | } 109 | get { 110 | return textView.text 111 | } 112 | } 113 | /// The font of the text. 114 | open var font: UIFont? { 115 | set { 116 | textView.font = newValue 117 | updateMaxHeight() 118 | updateMinHeight() 119 | } 120 | get { 121 | return textView.font 122 | } 123 | } 124 | /// The color of the text. 125 | /// 126 | /// This property applies to the entire text string. The default text color is black. 127 | open var textColor: UIColor? { 128 | set { 129 | textView.textColor = newValue 130 | } 131 | get { 132 | return textView.textColor 133 | } 134 | } 135 | /// The technique to use for aligning the text. 136 | /// 137 | /// This property applies to the entire text string. The default value of this property is NSTextAlignment.left. 138 | open var textAlignment: NSTextAlignment { 139 | set { 140 | textView.textAlignment = newValue 141 | } 142 | get { 143 | return textView.textAlignment 144 | } 145 | } 146 | /// A Boolean value indicating whether the receiver is editable. 147 | /// 148 | /// The default value of this property is true. 149 | open var isEditable: Bool { 150 | set { 151 | textView.isEditable = newValue 152 | } 153 | get { 154 | return textView.isEditable 155 | } 156 | } 157 | /// The current selection range of the receiver. 158 | open var selectedRange: NSRange? { 159 | set { 160 | if let newValue = newValue { 161 | textView.selectedRange = newValue 162 | } 163 | } 164 | get { 165 | return textView.selectedRange 166 | } 167 | } 168 | /// The types of data converted to clickable URLs in the text view. 169 | /// 170 | /// You can use this property to specify the types of data (phone numbers, http links, and so on) that should be automatically converted to clickable URLs in the text view. When clicked, the text view opens the application responsible for handling the URL type and passes it the URL. 171 | open var dataDetectorTypes: UIDataDetectorTypes { 172 | set { 173 | textView.dataDetectorTypes = newValue 174 | } 175 | get { 176 | return textView.dataDetectorTypes 177 | } 178 | } 179 | /// The visible title of the Return key. 180 | /// 181 | /// Setting this property to a different key type changes the visible title of the Return key and typically results in the keyboard being dismissed when it is pressed. The default value for this property is UIReturnKeyType.default. 182 | open var returnKeyType: UIReturnKeyType { 183 | set { 184 | textView.returnKeyType = newValue 185 | } 186 | get { 187 | return textView.returnKeyType 188 | } 189 | } 190 | /// The keyboard style of the text view. 191 | /// 192 | /// Text view can be targeted for specific types of input, such as plain text, email, numeric entry, and so on. The keyboard style identifies what keys are available on the keyboard and which ones appear by default. The default value for this property is UIKeyboardType.default. 193 | open var keyboardType: UIKeyboardType { 194 | set { 195 | textView.keyboardType = newValue 196 | } 197 | get { 198 | return textView.keyboardType 199 | } 200 | } 201 | /// A Boolean value indicating whether the Return key is automatically enabled when the user is entering text. 202 | /// 203 | /// The default value for this property is false. If you set it to true, the keyboard disables the Return key when the text entry area contains no text. As soon as the user enters some text, the Return key is automatically enabled. 204 | open var enablesReturnKeyAutomatically: Bool { 205 | set { 206 | textView.enablesReturnKeyAutomatically = newValue 207 | } 208 | get { 209 | return textView.enablesReturnKeyAutomatically 210 | } 211 | } 212 | /// A Boolean value indicating whether the text view currently contains any text. 213 | open var hasText: Bool { 214 | return textView.hasText 215 | } 216 | 217 | // MARK: - Private properties 218 | fileprivate var textView: GrowingInternalTextView = { 219 | let textView = GrowingInternalTextView(frame: .zero) 220 | textView.textContainerInset = .zero 221 | textView.textContainer.lineFragmentPadding = 1 // 1 pixel for caret 222 | textView.showsHorizontalScrollIndicator = false 223 | textView.contentInset = .zero 224 | textView.contentMode = .redraw 225 | return textView 226 | }() 227 | 228 | // MARK: - Initialization 229 | public override init(frame: CGRect) { 230 | super.init(frame: frame) 231 | commonInit() 232 | } 233 | 234 | required public init?(coder aDecoder: NSCoder) { 235 | super.init(coder: aDecoder) 236 | commonInit() 237 | } 238 | } 239 | 240 | // MARK: - Overriding 241 | extension GrowingTextView { 242 | open override var backgroundColor: UIColor? { 243 | didSet { 244 | textView.backgroundColor = backgroundColor 245 | } 246 | } 247 | 248 | open override func layoutSubviews() { 249 | super.layoutSubviews() 250 | updateTextViewFrame() 251 | updateMaxHeight() 252 | updateMinHeight() 253 | updateHeight() 254 | } 255 | 256 | open override func sizeThatFits(_ size: CGSize) -> CGSize { 257 | var size = size 258 | if text?.count == 0 { 259 | size.height = minHeight 260 | } 261 | return size 262 | } 263 | 264 | open override func touchesEnded(_ touches: Set, with event: UIEvent?) { 265 | textView.becomeFirstResponder() 266 | } 267 | 268 | open override func becomeFirstResponder() -> Bool { 269 | super.becomeFirstResponder() 270 | return textView.becomeFirstResponder() 271 | } 272 | 273 | open override func resignFirstResponder() -> Bool { 274 | super.resignFirstResponder() 275 | return textView.resignFirstResponder() 276 | } 277 | 278 | open override var isFirstResponder: Bool { 279 | return textView.isFirstResponder 280 | } 281 | } 282 | 283 | // MARK: - Public 284 | extension GrowingTextView { 285 | public func scrollRangeToVisible(_ range: NSRange) { 286 | textView.scrollRangeToVisible(range) 287 | } 288 | 289 | public func calculateHeight() -> CGFloat { 290 | return ceil(textView.sizeThatFits(textView.frame.size).height + contentInset.top + contentInset.bottom) 291 | } 292 | 293 | public func updateHeight() { 294 | let updatedHeightInfo = updatedHeight() 295 | let newHeight = updatedHeightInfo.newHeight 296 | let difference = updatedHeightInfo.difference 297 | 298 | if difference != 0 { 299 | if newHeight == maxHeight { 300 | if !textView.isScrollEnabled { 301 | textView.isScrollEnabled = true 302 | textView.flashScrollIndicators() 303 | } 304 | } else { 305 | textView.isScrollEnabled = isScrollEnabled 306 | } 307 | 308 | if isGrowingAnimationEnabled { 309 | UIView.animate(withDuration: animationDuration, delay: 0, options: [.allowUserInteraction, .beginFromCurrentState], animations: { 310 | self.updateGrowingTextView(newHeight: newHeight, difference: difference) 311 | }, completion: { (_) in 312 | if let delegate = self.delegate, delegate.responds(to: DelegateSelectors.didChangeHeight) { 313 | delegate.growingTextView!(self, didChangeHeight: newHeight, difference: difference) 314 | } 315 | }) 316 | } else { 317 | updateGrowingTextView(newHeight: newHeight, difference: difference) 318 | 319 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.didChangeHeight) { 320 | delegate.growingTextView!(self, didChangeHeight: newHeight, difference: difference) 321 | } 322 | } 323 | } 324 | 325 | updateScrollPosition(animated: false) 326 | textView.shouldDisplayPlaceholder = textView.text.isEmpty && isPlaceholderEnabled 327 | } 328 | } 329 | 330 | // MARK: - Helper 331 | extension GrowingTextView { 332 | fileprivate func commonInit() { 333 | textView.frame = CGRect(origin: .zero, size: frame.size) 334 | textView.delegate = self 335 | minNumberOfLines = 1 336 | addSubview(textView) 337 | } 338 | 339 | fileprivate func updateTextViewFrame() { 340 | let lineFragmentPadding = textView.textContainer.lineFragmentPadding 341 | var textViewFrame = frame 342 | textViewFrame.origin.x = contentInset.left - lineFragmentPadding 343 | textViewFrame.origin.y = contentInset.top 344 | textViewFrame.size.width -= contentInset.left + contentInset.right - lineFragmentPadding * 2 345 | textViewFrame.size.height -= contentInset.top + contentInset.bottom 346 | textView.frame = textViewFrame 347 | textView.sizeThatFits(textView.frame.size) 348 | } 349 | 350 | fileprivate func updateGrowingTextView(newHeight: CGFloat, difference: CGFloat) { 351 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.willChangeHeight) { 352 | delegate.growingTextView!(self, willChangeHeight: newHeight, difference: difference) 353 | } 354 | frame.size.height = newHeight 355 | updateTextViewFrame() 356 | } 357 | 358 | fileprivate func updatedHeight() -> (newHeight: CGFloat, difference: CGFloat) { 359 | var newHeight = calculateHeight() 360 | if newHeight < minHeight || !hasText { 361 | newHeight = minHeight 362 | } 363 | if let maxHeight = maxHeight, newHeight > maxHeight { 364 | newHeight = maxHeight 365 | } 366 | let difference = newHeight - frame.height 367 | 368 | return (newHeight, difference) 369 | } 370 | 371 | fileprivate func heightForNumberOfLines(_ numberOfLines: Int) -> CGFloat { 372 | var text = "-" 373 | if numberOfLines > 0 { 374 | for _ in 1.. Bool { 425 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.shouldBeginEditing) { 426 | return delegate.growingTextViewShouldBeginEditing!(self) 427 | } 428 | return true 429 | } 430 | 431 | public func textViewShouldEndEditing(_ textView: UITextView) -> Bool { 432 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.shouldEndEditing) { 433 | return delegate.growingTextViewShouldEndEditing!(self) 434 | } 435 | return true 436 | } 437 | 438 | public func textViewDidBeginEditing(_ textView: UITextView) { 439 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.didBeginEditing) { 440 | delegate.growingTextViewDidBeginEditing!(self) 441 | } 442 | } 443 | 444 | public func textViewDidEndEditing(_ textView: UITextView) { 445 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.didEndEditing) { 446 | delegate.growingTextViewDidEndEditing!(self) 447 | } 448 | } 449 | 450 | public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { 451 | if !hasText && text == "" { 452 | return false 453 | } 454 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.shouldChangeText) { 455 | return delegate.growingTextView!(self, shouldChangeTextInRange: range, replacementText: text) 456 | } 457 | 458 | if text == "\n" { 459 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.shouldReturn) { 460 | return delegate.growingTextViewShouldReturn!(self) 461 | } else { 462 | textView.resignFirstResponder() 463 | return false 464 | } 465 | } 466 | return true 467 | } 468 | 469 | public func textViewDidChange(_ textView: UITextView) { 470 | updateHeight() 471 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.didChange) { 472 | delegate.growingTextViewDidChange!(self) 473 | } 474 | } 475 | 476 | public func textViewDidChangeSelection(_ textView: UITextView) { 477 | let willUpdateHeight = updatedHeight().difference != 0 478 | if !willUpdateHeight { 479 | updateScrollPosition(animated: true) 480 | } 481 | if let delegate = delegate, delegate.responds(to: DelegateSelectors.didChangeSelection) { 482 | delegate.growingTextViewDidChangeSelection!(self) 483 | } 484 | } 485 | } 486 | -------------------------------------------------------------------------------- /GrowingTextView/Protocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Protocol.swift 3 | // GrowingTextView 4 | // 5 | // Created by Xin Hong on 16/2/16. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public protocol GrowingTextViewDelegate: NSObjectProtocol { 12 | @objc optional func growingTextViewShouldBeginEditing(_ growingTextView: GrowingTextView) -> Bool 13 | @objc optional func growingTextViewShouldEndEditing(_ growingTextView: GrowingTextView) -> Bool 14 | 15 | @objc optional func growingTextViewDidBeginEditing(_ growingTextView: GrowingTextView) 16 | @objc optional func growingTextViewDidEndEditing(_ growingTextView: GrowingTextView) 17 | 18 | @objc optional func growingTextView(_ growingTextView: GrowingTextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool 19 | @objc optional func growingTextViewDidChange(_ growingTextView: GrowingTextView) 20 | @objc optional func growingTextViewDidChangeSelection(_ growingTextView: GrowingTextView) 21 | 22 | @objc optional func growingTextView(_ growingTextView: GrowingTextView, willChangeHeight height: CGFloat, difference: CGFloat) 23 | @objc optional func growingTextView(_ growingTextView: GrowingTextView, didChangeHeight height: CGFloat, difference: CGFloat) 24 | 25 | @objc optional func growingTextViewShouldReturn(_ growingTextView: GrowingTextView) -> Bool 26 | } 27 | 28 | internal struct DelegateSelectors { 29 | static let shouldBeginEditing = #selector(GrowingTextViewDelegate.growingTextViewShouldBeginEditing(_:)) 30 | static let shouldEndEditing = #selector(GrowingTextViewDelegate.growingTextViewShouldEndEditing(_:)) 31 | static let didBeginEditing = #selector(GrowingTextViewDelegate.growingTextViewDidBeginEditing(_:)) 32 | static let didEndEditing = #selector(GrowingTextViewDelegate.growingTextViewDidEndEditing(_:)) 33 | static let shouldChangeText = #selector(GrowingTextViewDelegate.growingTextView(_:shouldChangeTextInRange:replacementText:)) 34 | static let didChange = #selector(GrowingTextViewDelegate.growingTextViewDidChange(_:)) 35 | static let didChangeSelection = #selector(GrowingTextViewDelegate.growingTextViewDidChangeSelection(_:)) 36 | static let willChangeHeight = #selector(GrowingTextViewDelegate.growingTextView(_:willChangeHeight:difference:)) 37 | static let didChangeHeight = #selector(GrowingTextViewDelegate.growingTextView(_:didChangeHeight:difference:)) 38 | static let shouldReturn = #selector(GrowingTextViewDelegate.growingTextViewShouldReturn(_:)) 39 | } 40 | -------------------------------------------------------------------------------- /GrowingTextView/Supporting Files/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 | 0.1.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /GrowingTextViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D3913F0E1C72EBAA00AB3B29 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3913F0D1C72EBAA00AB3B29 /* AppDelegate.swift */; }; 11 | D3913F101C72EBAA00AB3B29 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3913F0F1C72EBAA00AB3B29 /* ExampleViewController.swift */; }; 12 | D3913F131C72EBAA00AB3B29 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D3913F111C72EBAA00AB3B29 /* Main.storyboard */; }; 13 | D3913F151C72EBAA00AB3B29 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D3913F141C72EBAA00AB3B29 /* Assets.xcassets */; }; 14 | D3913F3A1C72EEA000AB3B29 /* GrowingTextView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3913F391C72EEA000AB3B29 /* GrowingTextView.framework */; }; 15 | D3913F3B1C72EEA000AB3B29 /* GrowingTextView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D3913F391C72EEA000AB3B29 /* GrowingTextView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | D3DA9AD81C744A2400D7B4F8 /* LeftMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DA9AD71C744A2400D7B4F8 /* LeftMessageCell.swift */; }; 17 | D3DA9ADA1C744A3600D7B4F8 /* RightMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DA9AD91C744A3600D7B4F8 /* RightMessageCell.swift */; }; 18 | D3DA9ADC1C74957800D7B4F8 /* MessageLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3DA9ADB1C74957800D7B4F8 /* MessageLabel.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXCopyFilesBuildPhase section */ 22 | D3913F3C1C72EEA100AB3B29 /* Embed Frameworks */ = { 23 | isa = PBXCopyFilesBuildPhase; 24 | buildActionMask = 2147483647; 25 | dstPath = ""; 26 | dstSubfolderSpec = 10; 27 | files = ( 28 | D3913F3B1C72EEA000AB3B29 /* GrowingTextView.framework in Embed Frameworks */, 29 | ); 30 | name = "Embed Frameworks"; 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXCopyFilesBuildPhase section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | D3913F0A1C72EBAA00AB3B29 /* GrowingTextViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GrowingTextViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | D3913F0D1C72EBAA00AB3B29 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | D3913F0F1C72EBAA00AB3B29 /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = ""; }; 39 | D3913F121C72EBAA00AB3B29 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | D3913F141C72EBAA00AB3B29 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 41 | D3913F191C72EBAA00AB3B29 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | D3913F391C72EEA000AB3B29 /* GrowingTextView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = GrowingTextView.framework; path = "/Users/hongxin/Library/Developer/Xcode/DerivedData/GrowingTextView-crgyyrnlpfkercemdxohtbbudazx/Build/Products/Debug-iphoneos/GrowingTextView.framework"; sourceTree = ""; }; 43 | D3DA9AD71C744A2400D7B4F8 /* LeftMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftMessageCell.swift; sourceTree = ""; }; 44 | D3DA9AD91C744A3600D7B4F8 /* RightMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightMessageCell.swift; sourceTree = ""; }; 45 | D3DA9ADB1C74957800D7B4F8 /* MessageLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageLabel.swift; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | D3913F071C72EBAA00AB3B29 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | D3913F3A1C72EEA000AB3B29 /* GrowingTextView.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | D3913F011C72EBAA00AB3B29 = { 61 | isa = PBXGroup; 62 | children = ( 63 | D3913F391C72EEA000AB3B29 /* GrowingTextView.framework */, 64 | D3913F0C1C72EBAA00AB3B29 /* GrowingTextViewExample */, 65 | D3913F0B1C72EBAA00AB3B29 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | D3913F0B1C72EBAA00AB3B29 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | D3913F0A1C72EBAA00AB3B29 /* GrowingTextViewExample.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | D3913F0C1C72EBAA00AB3B29 /* GrowingTextViewExample */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | D3913F0D1C72EBAA00AB3B29 /* AppDelegate.swift */, 81 | D3DA9ADB1C74957800D7B4F8 /* MessageLabel.swift */, 82 | D3DA9AD71C744A2400D7B4F8 /* LeftMessageCell.swift */, 83 | D3DA9AD91C744A3600D7B4F8 /* RightMessageCell.swift */, 84 | D3913F0F1C72EBAA00AB3B29 /* ExampleViewController.swift */, 85 | D3913F111C72EBAA00AB3B29 /* Main.storyboard */, 86 | D3913F141C72EBAA00AB3B29 /* Assets.xcassets */, 87 | D3913F191C72EBAA00AB3B29 /* Info.plist */, 88 | ); 89 | path = GrowingTextViewExample; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | D3913F091C72EBAA00AB3B29 /* GrowingTextViewExample */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = D3913F1C1C72EBAA00AB3B29 /* Build configuration list for PBXNativeTarget "GrowingTextViewExample" */; 98 | buildPhases = ( 99 | D3913F061C72EBAA00AB3B29 /* Sources */, 100 | D3913F071C72EBAA00AB3B29 /* Frameworks */, 101 | D3913F081C72EBAA00AB3B29 /* Resources */, 102 | D3913F3C1C72EEA100AB3B29 /* Embed Frameworks */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = GrowingTextViewExample; 109 | productName = GrowingTextView; 110 | productReference = D3913F0A1C72EBAA00AB3B29 /* GrowingTextViewExample.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | D3913F021C72EBAA00AB3B29 /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastSwiftUpdateCheck = 0720; 120 | LastUpgradeCheck = 1020; 121 | ORGANIZATIONNAME = Teambition; 122 | TargetAttributes = { 123 | D3913F091C72EBAA00AB3B29 = { 124 | CreatedOnToolsVersion = 7.2.1; 125 | LastSwiftMigration = 1020; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = D3913F051C72EBAA00AB3B29 /* Build configuration list for PBXProject "GrowingTextViewExample" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = D3913F011C72EBAA00AB3B29; 138 | productRefGroup = D3913F0B1C72EBAA00AB3B29 /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | D3913F091C72EBAA00AB3B29 /* GrowingTextViewExample */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | D3913F081C72EBAA00AB3B29 /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | D3913F151C72EBAA00AB3B29 /* Assets.xcassets in Resources */, 153 | D3913F131C72EBAA00AB3B29 /* Main.storyboard in Resources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXResourcesBuildPhase section */ 158 | 159 | /* Begin PBXSourcesBuildPhase section */ 160 | D3913F061C72EBAA00AB3B29 /* Sources */ = { 161 | isa = PBXSourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | D3DA9ADA1C744A3600D7B4F8 /* RightMessageCell.swift in Sources */, 165 | D3913F101C72EBAA00AB3B29 /* ExampleViewController.swift in Sources */, 166 | D3DA9ADC1C74957800D7B4F8 /* MessageLabel.swift in Sources */, 167 | D3913F0E1C72EBAA00AB3B29 /* AppDelegate.swift in Sources */, 168 | D3DA9AD81C744A2400D7B4F8 /* LeftMessageCell.swift in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | D3913F111C72EBAA00AB3B29 /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | D3913F121C72EBAA00AB3B29 /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | D3913F1A1C72EBAA00AB3B29 /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_COMMA = YES; 198 | CLANG_WARN_CONSTANT_CONVERSION = YES; 199 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 200 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 201 | CLANG_WARN_EMPTY_BODY = YES; 202 | CLANG_WARN_ENUM_CONVERSION = YES; 203 | CLANG_WARN_INFINITE_RECURSION = YES; 204 | CLANG_WARN_INT_CONVERSION = YES; 205 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 206 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 207 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 210 | CLANG_WARN_STRICT_PROTOTYPES = YES; 211 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 212 | CLANG_WARN_UNREACHABLE_CODE = YES; 213 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 214 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 215 | COPY_PHASE_STRIP = NO; 216 | DEBUG_INFORMATION_FORMAT = dwarf; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | ENABLE_TESTABILITY = YES; 219 | GCC_C_LANGUAGE_STANDARD = gnu99; 220 | GCC_DYNAMIC_NO_PIC = NO; 221 | GCC_NO_COMMON_BLOCKS = YES; 222 | GCC_OPTIMIZATION_LEVEL = 0; 223 | GCC_PREPROCESSOR_DEFINITIONS = ( 224 | "DEBUG=1", 225 | "$(inherited)", 226 | ); 227 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 228 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 229 | GCC_WARN_UNDECLARED_SELECTOR = YES; 230 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 231 | GCC_WARN_UNUSED_FUNCTION = YES; 232 | GCC_WARN_UNUSED_VARIABLE = YES; 233 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 234 | MTL_ENABLE_DEBUG_INFO = YES; 235 | ONLY_ACTIVE_ARCH = YES; 236 | SDKROOT = iphoneos; 237 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 238 | TARGETED_DEVICE_FAMILY = "1,2"; 239 | }; 240 | name = Debug; 241 | }; 242 | D3913F1B1C72EBAA00AB3B29 /* Release */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_COMMA = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 256 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 257 | CLANG_WARN_EMPTY_BODY = YES; 258 | CLANG_WARN_ENUM_CONVERSION = YES; 259 | CLANG_WARN_INFINITE_RECURSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 263 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 264 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 265 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 266 | CLANG_WARN_STRICT_PROTOTYPES = YES; 267 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 271 | COPY_PHASE_STRIP = NO; 272 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 273 | ENABLE_NS_ASSERTIONS = NO; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | GCC_C_LANGUAGE_STANDARD = gnu99; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 284 | MTL_ENABLE_DEBUG_INFO = NO; 285 | SDKROOT = iphoneos; 286 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | VALIDATE_PRODUCT = YES; 289 | }; 290 | name = Release; 291 | }; 292 | D3913F1D1C72EBAA00AB3B29 /* Debug */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 296 | INFOPLIST_FILE = "$(SRCROOT)/GrowingTextViewExample/Info.plist"; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.GrowingTextViewExample; 299 | PRODUCT_NAME = GrowingTextViewExample; 300 | SWIFT_VERSION = 5.0; 301 | }; 302 | name = Debug; 303 | }; 304 | D3913F1E1C72EBAA00AB3B29 /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | INFOPLIST_FILE = "$(SRCROOT)/GrowingTextViewExample/Info.plist"; 309 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 310 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.GrowingTextViewExample; 311 | PRODUCT_NAME = GrowingTextViewExample; 312 | SWIFT_VERSION = 5.0; 313 | }; 314 | name = Release; 315 | }; 316 | /* End XCBuildConfiguration section */ 317 | 318 | /* Begin XCConfigurationList section */ 319 | D3913F051C72EBAA00AB3B29 /* Build configuration list for PBXProject "GrowingTextViewExample" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | D3913F1A1C72EBAA00AB3B29 /* Debug */, 323 | D3913F1B1C72EBAA00AB3B29 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | D3913F1C1C72EBAA00AB3B29 /* Build configuration list for PBXNativeTarget "GrowingTextViewExample" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | D3913F1D1C72EBAA00AB3B29 /* Debug */, 332 | D3913F1E1C72EBAA00AB3B29 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | /* End XCConfigurationList section */ 338 | }; 339 | rootObject = D3913F021C72EBAA00AB3B29 /* Project object */; 340 | } 341 | -------------------------------------------------------------------------------- /GrowingTextViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GrowingTextViewExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/GrowingTextViewExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /GrowingTextViewExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | GrowingTextViewExample.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D3913F091C72EBAA00AB3B29 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /GrowingTextViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GrowingTextViewExample 4 | // 5 | // Created by 洪鑫 on 16/2/16. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { 16 | return true 17 | } 18 | 19 | func applicationWillResignActive(_ application: UIApplication) { 20 | 21 | } 22 | 23 | func applicationDidEnterBackground(_ application: UIApplication) { 24 | 25 | } 26 | 27 | func applicationWillEnterForeground(_ application: UIApplication) { 28 | 29 | } 30 | 31 | func applicationDidBecomeActive(_ application: UIApplication) { 32 | 33 | } 34 | 35 | func applicationWillTerminate(_ application: UIApplication) { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /GrowingTextViewExample/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 | } -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/attachmentsIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "attachmentsIcon.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/attachmentsIcon.imageset/attachmentsIcon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba-archive/GrowingTextView/4917f8867494386c7143fc901dd051bbb30bfe62/GrowingTextViewExample/Assets.xcassets/attachmentsIcon.imageset/attachmentsIcon.pdf -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/emojiIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "emojiIcon.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/emojiIcon.imageset/emojiIcon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba-archive/GrowingTextView/4917f8867494386c7143fc901dd051bbb30bfe62/GrowingTextViewExample/Assets.xcassets/emojiIcon.imageset/emojiIcon.pdf -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/voiceIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "voiceIcon.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /GrowingTextViewExample/Assets.xcassets/voiceIcon.imageset/voiceIcon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba-archive/GrowingTextView/4917f8867494386c7143fc901dd051bbb30bfe62/GrowingTextViewExample/Assets.xcassets/voiceIcon.imageset/voiceIcon.pdf -------------------------------------------------------------------------------- /GrowingTextViewExample/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 | 25 | 26 | 27 | 35 | 36 | 37 | 38 | 39 | 47 | 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 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /GrowingTextViewExample/ExampleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleViewController.swift 3 | // GrowingTextViewExample 4 | // 5 | // Created by 洪鑫 on 16/2/16. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GrowingTextView 11 | 12 | class ExampleViewController: UIViewController { 13 | @IBOutlet weak var inputBarBottomSpace: NSLayoutConstraint! 14 | @IBOutlet weak var inputBarHeight: NSLayoutConstraint! 15 | @IBOutlet weak var textView: GrowingTextView! 16 | @IBOutlet weak var tableView: UITableView! 17 | 18 | fileprivate var messages = [String]() 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | setupUI() 23 | } 24 | 25 | deinit { 26 | NotificationCenter.default.removeObserver(self) 27 | } 28 | 29 | fileprivate func setupUI() { 30 | configureGrowingTextView() 31 | navigationItem.title = "GrowingTextView" 32 | automaticallyAdjustsScrollViewInsets = false 33 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil) 34 | NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil) 35 | } 36 | 37 | fileprivate func configureGrowingTextView() { 38 | textView.returnKeyType = .send 39 | textView.enablesReturnKeyAutomatically = true 40 | textView.font = .systemFont(ofSize: 16) 41 | textView.placeholder = NSAttributedString(string: "说点什么...", attributes: [.foregroundColor: UIColor.lightGray, .font: UIFont.systemFont(ofSize: 16)]) 42 | textView.maxNumberOfLines = 5 43 | textView.delegate = self 44 | } 45 | 46 | fileprivate func scrollToBottom(animated: Bool) { 47 | guard messages.count > 0 else { 48 | return 49 | } 50 | tableView.scrollToRow(at: IndexPath(row: 0, section: messages.count - 1), at: .bottom, animated: animated) 51 | } 52 | 53 | @objc func keyboardWillShow(_ notification: Notification) { 54 | if let keyboardFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue { 55 | inputBarBottomSpace.constant = keyboardFrame.height 56 | view.setNeedsLayout() 57 | view.layoutIfNeeded() 58 | scrollToBottom(animated: false) 59 | } 60 | } 61 | 62 | @objc func keyboardWillHide(_ notification: Notification) { 63 | inputBarBottomSpace.constant = 0 64 | view.setNeedsLayout() 65 | view.layoutIfNeeded() 66 | } 67 | } 68 | 69 | extension ExampleViewController: GrowingTextViewDelegate { 70 | func growingTextView(_ growingTextView: GrowingTextView, willChangeHeight height: CGFloat, difference: CGFloat) { 71 | print("Height Will Change To: \(height) Diff: \(difference)") 72 | 73 | inputBarHeight.constant = height 74 | view.setNeedsLayout() 75 | view.layoutIfNeeded() 76 | } 77 | 78 | func growingTextView(_ growingTextView: GrowingTextView, didChangeHeight height: CGFloat, difference: CGFloat) { 79 | print("Height Did Change!") 80 | } 81 | 82 | func growingTextViewShouldReturn(_ growingTextView: GrowingTextView) -> Bool { 83 | guard let text = growingTextView.text, !text.isEmpty else { 84 | return false 85 | } 86 | messages.append(text) 87 | growingTextView.text = nil 88 | tableView.beginUpdates() 89 | tableView.insertSections(IndexSet(integer: messages.count - 1), with: .fade) 90 | tableView.endUpdates() 91 | scrollToBottom(animated: true) 92 | return false 93 | } 94 | } 95 | 96 | extension ExampleViewController: UITableViewDataSource, UITableViewDelegate { 97 | fileprivate func isLeftMessageCell(withIndexPath indexPath: IndexPath) -> Bool { 98 | return indexPath.section % 2 == 0 99 | } 100 | 101 | fileprivate func isRightMessageCell(withIndexPath indexPath: IndexPath) -> Bool { 102 | return indexPath.section % 2 == 1 103 | } 104 | 105 | func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 106 | _ = textView.resignFirstResponder() 107 | } 108 | 109 | func numberOfSections(in tableView: UITableView) -> Int { 110 | return messages.count 111 | } 112 | 113 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 114 | return 1 115 | } 116 | 117 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 118 | return 10 119 | } 120 | 121 | func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 122 | return 10 123 | } 124 | 125 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 126 | let message = messages[indexPath.section] 127 | if isLeftMessageCell(withIndexPath: indexPath) { 128 | return LeftMessageCell.rowHeight(for: message) 129 | } else if isRightMessageCell(withIndexPath: indexPath) { 130 | return RightMessageCell.rowHeight(for: message) 131 | } 132 | return 0 133 | } 134 | 135 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 136 | let message = messages[indexPath.section] 137 | if isLeftMessageCell(withIndexPath: indexPath) { 138 | let cell = tableView.dequeueReusableCell(withIdentifier: kLeftMessageCellID, for: indexPath) as! LeftMessageCell 139 | cell.isUserInteractionEnabled = false 140 | cell.contentLabel.text = message 141 | cell.contentLabelTrainingSpace.constant = LeftMessageCell.trainingSpace(for: message) 142 | cell.layoutIfNeeded() 143 | return cell 144 | } else { 145 | let cell = tableView.dequeueReusableCell(withIdentifier: kRightMessageCellID, for: indexPath) as! RightMessageCell 146 | cell.isUserInteractionEnabled = false 147 | cell.contentLabel.text = message 148 | cell.contentLabelLeadingSpace.constant = RightMessageCell.leadingSpace(for: message) 149 | cell.layoutIfNeeded() 150 | return cell 151 | } 152 | } 153 | 154 | override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 155 | super.viewWillTransition(to: size, with: coordinator) 156 | tableView.reloadData() 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /GrowingTextViewExample/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 | APPL 17 | CFBundleShortVersionString 18 | 0.1.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 13 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /GrowingTextViewExample/LeftMessageCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LeftMessageCell.swift 3 | // GrowingTextViewExample 4 | // 5 | // Created by 洪鑫 on 16/2/17. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kLeftMessageCellID = "LeftMessageCell" 12 | private let leftPadding: CGFloat = 20 13 | private let rightPadding: CGFloat = UIScreen.main.bounds.width / 4 14 | 15 | class LeftMessageCell: UITableViewCell { 16 | @IBOutlet weak var contentLabel: MessageLabel! 17 | @IBOutlet weak var contentLabelTrainingSpace: NSLayoutConstraint! 18 | 19 | override func awakeFromNib() { 20 | super.awakeFromNib() 21 | contentLabel.layer.masksToBounds = true 22 | contentLabel.layer.cornerRadius = 6 23 | } 24 | 25 | class func rowHeight(for message: String) -> CGFloat { 26 | return contentLabelFrame(for: message).height + 15 27 | } 28 | 29 | class func trainingSpace(for message: String) -> CGFloat { 30 | return UIScreen.main.bounds.width - leftPadding - contentLabelFrame(for: message).width 31 | } 32 | 33 | fileprivate class func contentLabelFrame(for message: String) -> CGRect { 34 | guard !message.isEmpty else { 35 | return .zero 36 | } 37 | let messageString = message as NSString 38 | let size = CGSize(width: UIScreen.main.bounds.width - leftPadding - rightPadding, height: CGFloat.greatestFiniteMagnitude) 39 | let frame = messageString.boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: [.font: UIFont.systemFont(ofSize: 16)], context: nil) 40 | return CGRect(x: ceil(frame.origin.x), y: ceil(frame.origin.y), width: ceil(frame.width) + kMessageLabelPadding * 2.0, height: ceil(frame.height)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /GrowingTextViewExample/MessageLabel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MessageLabel.swift 3 | // GrowingTextViewExample 4 | // 5 | // Created by 洪鑫 on 16/2/17. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kMessageLabelPadding: CGFloat = 10 12 | 13 | class MessageLabel: UILabel { 14 | override func draw(_ rect: CGRect) { 15 | super.drawText(in: rect.inset(by: UIEdgeInsets(top: 0, left: kMessageLabelPadding, bottom: 0, right: kMessageLabelPadding))) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /GrowingTextViewExample/RightMessageCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RightMessageCell.swift 3 | // GrowingTextViewExample 4 | // 5 | // Created by 洪鑫 on 16/2/17. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let kRightMessageCellID = "RightMessageCell" 12 | private let leftPadding: CGFloat = UIScreen.main.bounds.width / 4 13 | private let rightPadding: CGFloat = 20 14 | 15 | class RightMessageCell: UITableViewCell { 16 | @IBOutlet weak var contentLabel: MessageLabel! 17 | @IBOutlet weak var contentLabelLeadingSpace: NSLayoutConstraint! 18 | 19 | override func awakeFromNib() { 20 | super.awakeFromNib() 21 | contentLabel.layer.masksToBounds = true 22 | contentLabel.layer.cornerRadius = 6 23 | } 24 | 25 | class func rowHeight(for message: String) -> CGFloat { 26 | return contentLabelFrame(for: message).height + 15 27 | } 28 | 29 | class func leadingSpace(for message: String) -> CGFloat { 30 | return UIScreen.main.bounds.width - rightPadding - contentLabelFrame(for: message).width 31 | } 32 | 33 | fileprivate class func contentLabelFrame(for message: String) -> CGRect { 34 | guard !message.isEmpty else { 35 | return .zero 36 | } 37 | let messageString = message as NSString 38 | let size = CGSize(width: UIScreen.main.bounds.width - leftPadding - rightPadding, height: CGFloat.greatestFiniteMagnitude) 39 | let frame = messageString.boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: [.font: UIFont.systemFont(ofSize: 16)], context: nil) 40 | return CGRect(x: ceil(frame.origin.x), y: ceil(frame.origin.y), width: ceil(frame.width) + kMessageLabelPadding * 2.0, height: ceil(frame.height)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Teambition 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GrowingTextView 2 | GrowingTextView is a text view which grows with the text changes and starts scrolling when the content reaches a specified number of lines. 3 | 4 | ![Example](Gif/GrowingTextViewExample.gif "GrowingTextViewExample") 5 | 6 | 7 | ## How To Get Started 8 | ### Carthage 9 | Specify "GrowingTextView" in your ```Cartfile```: 10 | ```ogdl 11 | github "teambition/GrowingTextView" 12 | ``` 13 | ### CocoaPods (version equal or above 0.1.4) 14 | 15 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 16 | 17 | ```bash 18 | $ gem install cocoapods 19 | ``` 20 | 21 | To integrate features into your Xcode project using CocoaPods, specify it in your `Podfile`: 22 | 23 | ```ruby 24 | source 'https://github.com/CocoaPods/Specs.git' 25 | platform :ios, '8.0' 26 | use_frameworks! 27 | 28 | pod 'TBGrowingTextView', '~> 0.1.4' 29 | ``` 30 | 31 | Then, run the following command: 32 | 33 | ```bash 34 | $ pod install 35 | ``` 36 | 37 | 38 | 39 | ### Usage 40 | #### Configuration 41 | ```swift 42 | textView.maxNumberOfLines = ... 43 | textView.minNumberOfLines = ... 44 | textView.maxHeight = ... 45 | textView.minHeight = ... 46 | textView.isGrowingAnimationEnabled = ... 47 | textView.animationDuration = ... 48 | textView.contentInset = ... 49 | textView.isScrollEnabled = ... 50 | textView.isPlaceholderEnabled = ... 51 | textView.placeholder = ... 52 | textView.text = ... 53 | textView.font = ... 54 | textView.textColor = ... 55 | textView.textAlignment = ... 56 | textView.isEditable = ... 57 | textView.selectedRange = ... 58 | textView.dataDetectorTypes = ... 59 | textView.returnKeyType = ... 60 | textView.keyboardType = ... 61 | textView.enablesReturnKeyAutomatically = ... 62 | 63 | // assign delegate 64 | textView.delegate = self 65 | ``` 66 | 67 | #### Implement delegate 68 | ```swift 69 | optional func growingTextViewShouldBeginEditing(_ growingTextView: GrowingTextView) -> Bool 70 | 71 | optional func growingTextViewShouldEndEditing(_ growingTextView: GrowingTextView) -> Bool 72 | 73 | optional func growingTextViewDidBeginEditing(_ growingTextView: GrowingTextView) 74 | 75 | optional func growingTextViewDidEndEditing(_ growingTextView: GrowingTextView) 76 | 77 | optional func growingTextView(_ growingTextView: GrowingTextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool 78 | 79 | optional func growingTextViewDidChange(_ growingTextView: GrowingTextView) 80 | 81 | optional func growingTextViewDidChangeSelection(_ growingTextView: GrowingTextView) 82 | 83 | optional func growingTextView(_ growingTextView: GrowingTextView, willChangeHeight height: CGFloat, difference: CGFloat) 84 | 85 | optional func growingTextView(_ growingTextView: GrowingTextView, didChangeHeight height: CGFloat, difference: CGFloat) 86 | 87 | optional func growingTextViewShouldReturn(_ growingTextView: GrowingTextView) -> Bool 88 | ``` 89 | 90 | ## Minimum Requirement 91 | iOS 8.0 92 | 93 | ## Release Notes 94 | * [Release Notes](https://github.com/teambition/GrowingTextView/releases) 95 | 96 | ## License 97 | GrowingTextView is released under the MIT license. See [LICENSE](https://github.com/teambition/GrowingTextView/blob/master/LICENSE.md) for details. 98 | 99 | ## More Info 100 | Have a question? Please [open an issue](https://github.com/teambition/GrowingTextView/issues/new)! 101 | -------------------------------------------------------------------------------- /TBGrowingTextView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | 3 | spec.name = "TBGrowingTextView" 4 | spec.version = "0.1.4" 5 | spec.summary = "TBGrowingTextView is a text view which grows with the text changes and starts scrolling when the content reaches a specified number of lines." 6 | 7 | spec.homepage = "https://github.com/teambition/GrowingTextView" 8 | spec.license = { :type => "MIT", :file => "LICENSE.md" } 9 | spec.author = { "bruce" => "liangmingzou@163.com" } 10 | spec.platform = :ios, "8.0" 11 | spec.source = { :git => "https://github.com/teambition/GrowingTextView.git", :tag => "#{spec.version}" } 12 | spec.swift_version = "5.0" 13 | 14 | spec.source_files = "GrowingTextView/*.swift" 15 | spec.frameworks = "Foundation", "UIKit" 16 | 17 | end --------------------------------------------------------------------------------