├── .gitignore ├── .travis.yml ├── Example ├── Podfile ├── Podfile.lock ├── Pods │ ├── Headers │ │ ├── Private │ │ │ ├── RZIntrinsicContentSizeTextView │ │ │ │ ├── RZIntrinsicContentSizeTextView.h │ │ │ │ ├── UIView+RZAutoLayoutHelpers.h │ │ │ │ ├── UIView+RZAutoLayoutPriorityHelpers.h │ │ │ │ └── UIView+RZAutoLayoutReplacementHelpers.h │ │ │ └── RZUtils │ │ │ │ ├── UIView+RZAutoLayoutHelpers.h │ │ │ │ ├── UIView+RZBorders.h │ │ │ │ └── UIView+RZFrameUtils.h │ │ └── Public │ │ │ ├── RZIntrinsicContentSizeTextView │ │ │ └── RZIntrinsicContentSizeTextView.h │ │ │ └── RZUtils │ │ │ ├── UIView+RZAutoLayoutHelpers.h │ │ │ ├── UIView+RZBorders.h │ │ │ └── UIView+RZFrameUtils.h │ ├── Local Podspecs │ │ └── RZIntrinsicContentSizeTextView.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ ├── RZUtils │ │ ├── LICENSE │ │ ├── README.md │ │ └── RZUtils │ │ │ └── Categories │ │ │ └── UIView │ │ │ ├── UIView+RZAutoLayoutHelpers.h │ │ │ ├── UIView+RZAutoLayoutHelpers.m │ │ │ ├── UIView+RZBorders.h │ │ │ ├── UIView+RZBorders.m │ │ │ ├── UIView+RZFrameUtils.h │ │ │ └── UIView+RZFrameUtils.m │ └── Target Support Files │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-Private.xcconfig │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-dummy.m │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-prefix.pch │ │ └── Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView.xcconfig │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZUtils │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZUtils-Private.xcconfig │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZUtils-dummy.m │ │ ├── Pods-RZIntrinsicContentSizeTextView-RZUtils-prefix.pch │ │ └── Pods-RZIntrinsicContentSizeTextView-RZUtils.xcconfig │ │ ├── Pods-RZIntrinsicContentSizeTextView │ │ ├── Pods-RZIntrinsicContentSizeTextView-acknowledgements.markdown │ │ ├── Pods-RZIntrinsicContentSizeTextView-acknowledgements.plist │ │ ├── Pods-RZIntrinsicContentSizeTextView-dummy.m │ │ ├── Pods-RZIntrinsicContentSizeTextView-environment.h │ │ ├── Pods-RZIntrinsicContentSizeTextView-resources.sh │ │ ├── Pods-RZIntrinsicContentSizeTextView.debug.xcconfig │ │ └── Pods-RZIntrinsicContentSizeTextView.release.xcconfig │ │ ├── Pods-Tests-RZIntrinsicContentSizeTextView │ │ ├── Pods-Tests-RZIntrinsicContentSizeTextView-Private.xcconfig │ │ ├── Pods-Tests-RZIntrinsicContentSizeTextView-dummy.m │ │ ├── Pods-Tests-RZIntrinsicContentSizeTextView-prefix.pch │ │ └── Pods-Tests-RZIntrinsicContentSizeTextView.xcconfig │ │ └── Pods-Tests │ │ ├── Pods-Tests-acknowledgements.markdown │ │ ├── Pods-Tests-acknowledgements.plist │ │ ├── Pods-Tests-dummy.m │ │ ├── Pods-Tests-environment.h │ │ ├── Pods-Tests-resources.sh │ │ ├── Pods-Tests.debug.xcconfig │ │ └── Pods-Tests.release.xcconfig ├── RZIntrinsicContentSizeTextView.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── RZIntrinsicContentSizeTextView-Example.xcscheme ├── RZIntrinsicContentSizeTextView.xcworkspace │ └── contents.xcworkspacedata ├── RZIntrinsicContentSizeTextView │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── RZAppDelegate.h │ ├── RZAppDelegate.m │ ├── RZIntrinsicContentSizeTextView-Info.plist │ ├── RZIntrinsicContentSizeTextView-Prefix.pch │ ├── RZViewController.h │ ├── RZViewController.m │ ├── RZViewController.xib │ ├── UIView+RZMinMaxAutoLayoutHelpers.h │ ├── UIView+RZMinMaxAutoLayoutHelpers.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── Tests │ ├── RZIntrinsicContentSizeTextViewUITest.m │ ├── RZIntrinsicSizeTextViewTest.m │ ├── RZTestConstants.h │ ├── RZTestConstants.m │ ├── Tests-Info.plist │ ├── Tests-Prefix.pch │ └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── Pod ├── Assets │ └── .gitkeep ├── Categories │ ├── UIView+RZAutoLayoutHelpers.h │ ├── UIView+RZAutoLayoutHelpers.m │ ├── UIView+RZAutoLayoutPriorityHelpers.h │ ├── UIView+RZAutoLayoutPriorityHelpers.m │ ├── UIView+RZAutoLayoutReplacementHelpers.h │ └── UIView+RZAutoLayoutReplacementHelpers.m └── Classes │ ├── RZIntrinsicContentSizeTextView.h │ └── RZIntrinsicContentSizeTextView.m ├── README.md └── RZIntrinsicContentSizeTextView.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | 18 | profile 19 | 20 | *.moved-aside 21 | DerivedData 22 | *.hmap 23 | *.ipa 24 | 25 | # Bundler 26 | .bundle 27 | 28 | # We recommend against adding the Pods directory to your .gitignore. However 29 | # you should judge for yourself, the pros and cons are mentioned at: 30 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 31 | # 32 | # Note: if you ignore the Pods directory, make sure to uncomment 33 | # `pod install` in .travis.yml 34 | # 35 | # Pods/ 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | language: objective-c 6 | # cache: cocoapods 7 | # podfile: Example/Podfile 8 | # before_install: 9 | # - gem install cocoapods # Since Travis is not always on latest version 10 | # - pod install --project-directory=Example 11 | install: 12 | - gem install xcpretty --no-rdoc --no-ri --no-document --quiet 13 | script: 14 | - set -o pipefail && xcodebuild test -workspace Example/RZIntrinsicContentSizeTextView.xcworkspace -scheme RZIntrinsicContentSizeTextView-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c 15 | - pod lib lint --quick 16 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | target 'RZIntrinsicContentSizeTextView', :exclusive => true do 4 | pod 'RZIntrinsicContentSizeTextView', :path => '../' 5 | pod 'RZUtils/Categories/UIView' 6 | end 7 | 8 | target 'Tests', :exclusive => true do 9 | pod 'RZIntrinsicContentSizeTextView', :path => '../' 10 | pod 'FRY' 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RZIntrinsicContentSizeTextView (0.1.0) 3 | - RZUtils/Categories/UIView (2.4.0) 4 | 5 | DEPENDENCIES: 6 | - RZIntrinsicContentSizeTextView (from `../`) 7 | - RZUtils/Categories/UIView 8 | 9 | EXTERNAL SOURCES: 10 | RZIntrinsicContentSizeTextView: 11 | :path: ../ 12 | 13 | SPEC CHECKSUMS: 14 | RZIntrinsicContentSizeTextView: 1186d51e732a7c96cf31b320094a0f8d33d31e05 15 | RZUtils: 51a759b13f362b49bdd426f96440c75249b16453 16 | 17 | COCOAPODS: 0.36.0 18 | -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZIntrinsicContentSizeTextView/RZIntrinsicContentSizeTextView.h: -------------------------------------------------------------------------------- 1 | ../../../../../Pod/Classes/RZIntrinsicContentSizeTextView.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZIntrinsicContentSizeTextView/UIView+RZAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | ../../../../../Pod/Categories/UIView+RZAutoLayoutHelpers.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZIntrinsicContentSizeTextView/UIView+RZAutoLayoutPriorityHelpers.h: -------------------------------------------------------------------------------- 1 | ../../../../../Pod/Categories/UIView+RZAutoLayoutPriorityHelpers.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZIntrinsicContentSizeTextView/UIView+RZAutoLayoutReplacementHelpers.h: -------------------------------------------------------------------------------- 1 | ../../../../../Pod/Categories/UIView+RZAutoLayoutReplacementHelpers.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZUtils/UIView+RZAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZAutoLayoutHelpers.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZUtils/UIView+RZBorders.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZBorders.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/RZUtils/UIView+RZFrameUtils.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZFrameUtils.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/RZIntrinsicContentSizeTextView/RZIntrinsicContentSizeTextView.h: -------------------------------------------------------------------------------- 1 | ../../../../../Pod/Classes/RZIntrinsicContentSizeTextView.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/RZUtils/UIView+RZAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZAutoLayoutHelpers.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/RZUtils/UIView+RZBorders.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZBorders.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/RZUtils/UIView+RZFrameUtils.h: -------------------------------------------------------------------------------- 1 | ../../../RZUtils/RZUtils/Categories/UIView/UIView+RZFrameUtils.h -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/RZIntrinsicContentSizeTextView.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RZIntrinsicContentSizeTextView", 3 | "version": "0.1.0", 4 | "summary": "RZIntrinsicContentSizeTextView is a UITextView that grows dynamically in height.", 5 | "homepage": "https://github.com/Raizlabs/RZIntrinsicContentSizeTextView.git", 6 | "license": "MIT", 7 | "authors": { 8 | "Derek Ostrander": "derek@raizlabs.com" 9 | }, 10 | "source": { 11 | "git": "https://github.com/Raizlabs/RZIntrinsicContentSizeTextView.git", 12 | "tag": "0.1.0" 13 | }, 14 | "platforms": { 15 | "ios": "8.0" 16 | }, 17 | "requires_arc": true, 18 | "source_files": "Pod/**/*", 19 | "public_header_files": "Pod/Classes/**/*.h" 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RZIntrinsicContentSizeTextView (0.1.0) 3 | - RZUtils/Categories/UIView (2.4.0) 4 | 5 | DEPENDENCIES: 6 | - RZIntrinsicContentSizeTextView (from `../`) 7 | - RZUtils/Categories/UIView 8 | 9 | EXTERNAL SOURCES: 10 | RZIntrinsicContentSizeTextView: 11 | :path: ../ 12 | 13 | SPEC CHECKSUMS: 14 | RZIntrinsicContentSizeTextView: 1186d51e732a7c96cf31b320094a0f8d33d31e05 15 | RZUtils: 51a759b13f362b49bdd426f96440c75249b16453 16 | 17 | COCOAPODS: 0.36.0 18 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Raizlabs and other contributors 2 | http://raizlabs.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/README.md: -------------------------------------------------------------------------------- 1 | # RZUtils 2 | 3 | A collection of helpful utilities and components for iOS development. 4 | 5 | ## Installation 6 | 7 | ### CocoaPods 8 | 9 | The podspec for RZUtils is fully segmented into subspecs by directory (effectively one subspec per individual category type or component). See below for examples. 10 | 11 | ##### All of RZUtils 12 | 13 | `pod 'RZUtils'` 14 | 15 | ##### All Categories 16 | 17 | `pod 'RZUtils/Categories'` 18 | 19 | ##### All Components 20 | 21 | `pod 'RZUtils/Components'` 22 | 23 | ##### All Utilities or Test Utilities 24 | 25 | `pod 'RZUtils/Utilities'`
26 | `pod 'RZUtils/TestUtilities'` 27 | 28 | ##### Specific Classes 29 | 30 | To import only a specific category, component, or utility, the subspec should mirror the directory structure. 31 | For example: 32 | 33 | `pod 'RZUtils/Categories/NSString'`
34 | `pod 'RZUtils/Categories/KVO'`
35 | `pod 'RZUtils/Components/RZProgressView'` 36 | 37 | ### Manual Installation 38 | 39 | Simply copy the relevant file into your project. If the files import any frameworks, link against those frameworks. 40 | 41 | ## Categories Overview 42 | 43 | ### CoreAnimation 44 | 45 | - **CAAnimation+RZBlocks** 46 | 47 | Completion blocks for `CAAnimation` 48 | 49 | ### KVO 50 | 51 | - **NSObject+RZBlockKVO** 52 | 53 | KVO with blocks and automatic observer removal on dealloc 54 | 55 | ### NSDate 56 | 57 | - **NSDate+RZExtensions** 58 | 59 | Common date manipulations 60 | 61 | ### NSDictionary 62 | 63 | - **NSDictionary+RZExtensions** 64 | 65 | Convenience methods for `NSDictionary` (`NSNull` check, etc) 66 | 67 | ### NSString 68 | 69 | - **NSAttributedString+RZExtensions** 70 | 71 | Simplified attributed string initializer and other utils 72 | 73 | - **NSString+RZStringFormatting** 74 | 75 | Common string formatting methods 76 | 77 | - **NSString+RZStringSize** 78 | 79 | Replacement for string sizing methods deprecated in iOS 7. 80 | 81 | 82 | ### NSUndoManager 83 | 84 | - **NSUndoManager+RZBlockUndo** 85 | 86 | Block-based interface for undo manager. 87 | 88 | ### UIAlertView 89 | 90 | - **UIAlertView+RZCompletionBlocks** 91 | 92 | Block API for `UIAlertView` actions 93 | 94 | ### UIColor 95 | 96 | - **UIColor+RZExtensions** 97 | 98 | UIColor creation utilities 99 | 100 | ### UIFont 101 | 102 | - **UIFont+RZExtensions** 103 | 104 | Funky fresh font features 105 | 106 | ### UIImage 107 | 108 | - **UIImage+RZAverageColor** 109 | 110 | Calculates the average color of a UIImage instance. 111 | 112 | - **UIImage+RZResize** 113 | 114 | Methods for resizing an image given an aspect ratio. 115 | 116 | - **UIImage+RZSnapshotHelpers** 117 | 118 | Method for snapshotting and creating a UIImage from a UIView using iOS7's `drawViewHierarchyInRect`. Contains a faster version of Apple's image blur method for iOS7 (with view screenshot). iOS7+ only. 119 | 120 | - **UIImage+RZSolidColor** 121 | 122 | Category on `UIImage` to return a solid color image of a specified size. Especially useful to set a state-dependent background color on `UIButton`, like: `[aButton setBackgroundImage:[UIImage rz_solidColorImageWithSize:CGSizeMake(1.0f, 1.0f) color:[UIColor redColor]]]`. 123 | 124 | - **UIImage+RZStretchHelpers** 125 | 126 | Stretch and cap inset methods for `UIImage` 127 | 128 | ### UITableViewCell 129 | 130 | - **UITableViewCell+RZCellStyling** 131 | 132 | Methods for styling top, bottom, and middle tableview cells for grouped table views 133 | 134 | ### UIView 135 | 136 | - **UIView+RZAutoLayoutHelpers** 137 | 138 | Common code-level autolayout tasks made easier. 139 | 140 | - **UIView+RZBorders** 141 | 142 | Borders on arbitrary sides of any `UIView` 143 | 144 | - **UIView+RZFrameUtils** 145 | 146 | Easy adjustments to `UIView` frames 147 | 148 | ### UIViewController 149 | 150 | - **UIViewController+RZKeyboardWatcher** 151 | 152 | Utility for scripting animation blocks in response to keyboard appearance/disappearance notifications. 153 | 154 | ## Components Overview 155 | 156 | #### RZAnimatedCountingLabel 157 | 158 | `UILabel` subclass that animates its text from one value to another with an optional custom formatting block. 159 | 160 | #### RZAnimatedImageView 161 | 162 | Replacement for `UIImageView`-based animated .png sequences that calls a completion block when the animation is finished. Believe it or not, there is no way to do this otherwise. 163 | 164 | #### RZButtonView 165 | 166 | `UIControl` subclass that acts like a UIButton but allows the addition and layout of arbitrary subviews. 167 | 168 | #### RZCollectionTableView 169 | 170 | Is it a Collection View or a Table View? The world may never know... (**Spoiler**: It's a Collection View) 171 | 172 | `RZCollectionTableView` is a collection view layout and accompanying collection view and collection view cell subclasses that mimic the class/delegate interface, look, and feel of `UITableView`, with a few added enhancements such as customizable section insets, row spacings, and more. 173 | 174 | #### RZCollectionViewAnimationAssistant 175 | 176 | Utility for making collection view item insertion/deletion animations easier. 177 | 178 | #### RZDelayedOperation 179 | 180 | Basic concurrent NSOperation class that takes a block and executes it after a given time interval. Can be cancelled or reset. 181 | 182 | #### RZLocationService 183 | 184 | CoreLocation made easy. 185 | 186 | #### RZProgressView 187 | 188 | `UIProgressView` is a little broken in iOS 7.0 (weird glitches when animating and resizing), and very broken in iOS 7.1 (can't set custom images; radar [here](http://www.openradar.me/16113307)). `RZProgressView` is a drop-in replacement that fixes these problems. 189 | 190 | #### RZRevealViewController 191 | 192 | A basement/reveal menu component. 193 | 194 | #### RZSegmentedViewController 195 | 196 | `UIViewController` container that uses a segment control to switch between an array of `UIViewControllers` 197 | 198 | #### RZSingleChildContainerViewController 199 | 200 | A `UIViewController` subclass for managing a single child view controller contained in any subview container of a parent. Useful for keeping one view static while another view contains one of many potential child view controllers. iOS7+ only. 201 | 202 | #### RZSplitViewController 203 | 204 | Extends the functionality of `UISplitViewController` including allowing it to be presented Modally. 205 | 206 | #### RZTelprompt 207 | 208 | Makes NSURLRequest phone calls that use telprompt by making a tel request to a static UIWebView, which in turn privately calls telprompt. This gives you the benifits of using telprompt without calling it from UIApplication where it is not specifically supported by Apple. 209 | 210 | #### RZViewFactory 211 | 212 | Extensions to `UIView` for easily loading a subclass from a XIB file. 213 | 214 | #### RZWebviewController 215 | 216 | `UIViewController` that manages a web view, with associated chrome. 217 | 218 | 219 | ## Utilities Overview 220 | 221 | #### RZCommonUtils 222 | 223 | Useful macros, mathematical functions, and more. 224 | 225 | #### RZDispatch 226 | 227 | Useful extensions for working with GCD/libdispatch. 228 | 229 | #### RZLogHelper 230 | 231 | A header with debug log macros that extend `NSLog`, including verbosity levels. 232 | 233 | ## Test Utilities Overview 234 | 235 | All utilities within this directory are intended for use in test code ONLY. 236 | 237 | #### RZWaiter 238 | 239 | A utility for aiding in testing asynchronous operations. 240 | 241 | 242 | ## License 243 | 244 | RZUtils is distributed under an [MIT License](http://opensource.org/licenses/MIT). See the LICENSE file for more details. 245 | 246 | ## Contributing 247 | 248 | Contributions and pull requests are welcome. Please adhere to the following guidelines: 249 | 250 | - Please open Pull Requests against the `develop` branch. We periodically coalesce updates into tagged releases with semantic version numbers, which are pushed as podspec updates then merged to master. 251 | - Ensure that headers are documented using appledoc-style comments. This will allow CocoaDocs to automatically create documentation when the updated podspec is pushed. 252 | - Aggressively use prefixes (`RZ` for classes, `rz_` for methods) for category methods and class names in order to avoid potential naming collisions. 253 | 254 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutHelpers.h 3 | // 4 | // Created by Nick Donaldson on 10/22/13. 5 | 6 | // Copyright 2014 Raizlabs and other contributors 7 | // http://raizlabs.com/ 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | /** 32 | * Less-verbose implementations of common tasks when using autolayout. 33 | * More complex tasks with specific constants should be implemented elsewhere. 34 | * 35 | * @note Unless documented otherwise, each method which creates constraints also returns the constraint 36 | * (or constraints) that were added. 37 | * 38 | * @warning These methods make NO guarantee about existing constraints. If you've already added constraints, 39 | * it's up to you to make sure that adding these won't break your layout. 40 | */ 41 | @interface UIView (RZAutoLayoutHelpers) 42 | 43 | /** @name Helpers */ 44 | 45 | /** 46 | * Return the common ancestor shared by all the views passed in, if it exists. 47 | * 48 | * @return The common ancestor. 49 | */ 50 | + (UIView *)rztv_commonAncestorForViews:(NSArray *)views; 51 | 52 | /** @name Constraint Getters */ 53 | 54 | /** 55 | * Return the receiver's pinned width constraint, if it exsists. 56 | * 57 | * @return The constraint or nil. 58 | */ 59 | - (NSLayoutConstraint*)rztv_pinnedWidthConstraint; 60 | 61 | /** 62 | * Return the receiver's pinned height constraint, if it exsists. 63 | * 64 | * @return The constraint or nil. 65 | */ 66 | - (NSLayoutConstraint*)rztv_pinnedHeightConstraint; 67 | 68 | /** 69 | * Return the receiver's pinned top constraint, if it exsists. 70 | * 71 | * @return The constraint or nil. 72 | */ 73 | - (NSLayoutConstraint*)rztv_pinnedTopConstraint; 74 | 75 | /** 76 | * Return the receiver's pinned left side constraint, if it exsists. 77 | * 78 | * @return The constraint or nil. 79 | */ 80 | - (NSLayoutConstraint*)rztv_pinnedLeftConstraint; 81 | 82 | /** 83 | * Return the receiver's pinned right side constraint, if it exsists. 84 | * 85 | * @return The constraint or nil. 86 | */ 87 | - (NSLayoutConstraint*)rztv_pinnedRightConstraint; 88 | 89 | /** 90 | * Return the receiver's pinned bottom constraint, if it exsists. 91 | * 92 | * @return The constraint or nil. 93 | */ 94 | - (NSLayoutConstraint*)rztv_pinnedBottomConstraint; 95 | 96 | /** 97 | * Return the receiver's pinned center X constraint, if it exsists. 98 | * 99 | * @return The constraint or nil. 100 | */ 101 | - (NSLayoutConstraint*)rztv_pinnedCenterXConstraint; 102 | 103 | /** 104 | * Return the receiver's pinned center Y constraint, if it exsists. 105 | * 106 | * @return The constraint or nil. 107 | */ 108 | - (NSLayoutConstraint*)rztv_pinnedCenterYConstraint; 109 | 110 | /** @name Constraint Creation */ 111 | 112 | /** 113 | * Pin the receiver's width to a constant. 114 | * 115 | * @param width Deisred width. 116 | * 117 | * @return The pinned width constraint that was added. 118 | */ 119 | - (NSLayoutConstraint *)rztv_pinWidthTo:(CGFloat)width; 120 | 121 | /** 122 | * Pin the receiver's width to the width of another view. 123 | * 124 | * @param view The view to pin width to. 125 | * 126 | * @return The pinned width constraint that was added. 127 | */ 128 | - (NSLayoutConstraint *)rztv_pinWidthToView:(UIView *)view; 129 | 130 | /** 131 | * Pin the receiver's width to the width of another view with a particular multiplier. 132 | * 133 | * @param view The view to pin width to. 134 | * @param multiplier The multiplier to use for the pinning. 1.0 = exact width, 0.5 = half the width, etc. 135 | * 136 | * @note The constant on the returned constraint may also be edited. 137 | * 138 | * @return The pinned width constraint that was added. 139 | */ 140 | - (NSLayoutConstraint *)rztv_pinWidthToView:(UIView *)view multiplier:(CGFloat)multiplier; 141 | 142 | /** 143 | * Pin the receiver's width to a constant. 144 | * 145 | * @param width Deisred height. 146 | * 147 | * @return The pinned height constraint that was added. 148 | */ 149 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height; 150 | 151 | /** 152 | * Pin the receiver's height to the height of another view. 153 | * 154 | * @param view The view to pin height to. 155 | * 156 | * @return The pinned height constraint that was added. 157 | */ 158 | - (NSLayoutConstraint *)rztv_pinHeightToView:(UIView *)view; 159 | 160 | /** 161 | * Pin the receiver's height to the height of another view with a particular multiplier. 162 | * 163 | * @param view The view to pin height to. 164 | * @param multiplier The multiplier to use for the pinning. 1.0 = exact height, 0.5 = half the height, etc. 165 | * 166 | * @note The constant on the returned constraint may also be edited. 167 | * 168 | * @return The pinned height constraint that was added. 169 | */ 170 | - (NSLayoutConstraint *)rztv_pinHeightToView:(UIView *)view multiplier:(CGFloat)multiplier; 171 | 172 | /** 173 | * Pin the receiver's size to a particular value. 174 | * 175 | * @param size The size to pin to. 176 | * 177 | * @return The constraints that were added: [width, height]. 178 | */ 179 | - (NSArray *)rztv_pinSizeTo:(CGSize)size; 180 | 181 | /** 182 | * Pin the receiver's top space to its superview's top with a fixed amount of padding. 183 | * 184 | * @param padding The amount of padding between the top of the receiver and the superview. 185 | * 186 | * @warning The receiver must have a superview when this method is called. 187 | * 188 | * @return The constraint that was added. 189 | */ 190 | - (NSLayoutConstraint *)rztv_pinTopSpaceToSuperviewWithPadding:(CGFloat)padding; 191 | 192 | /** 193 | * Pin the receiver's left space to its superview's left side with a fixed amount of padding. 194 | * 195 | * @param padding The amount of padding between the left side of the receiver and the superview. 196 | * 197 | * @warning The receiver must have a superview when this method is called. 198 | * 199 | * @return The constraint that was added. 200 | */ 201 | - (NSLayoutConstraint *)rztv_pinLeftSpaceToSuperviewWithPadding:(CGFloat)padding; 202 | 203 | /** 204 | * Pin the receiver's bottom space to its superview's bottom with a fixed amount of padding. 205 | * 206 | * @param padding The amount of padding between the bottom of the receiver and the superview. 207 | * 208 | * @warning The receiver must have a superview when this method is called. 209 | * 210 | * @return The constraint that was added. 211 | */ 212 | - (NSLayoutConstraint *)rztv_pinBottomSpaceToSuperviewWithPadding:(CGFloat)padding; 213 | 214 | /** 215 | * Pin the receiver's right space to its superview's right side with a fixed amount of padding. 216 | * 217 | * @param padding The amount of padding between the right side of the receiver and the superview. 218 | * 219 | * @warning The receiver must have a superview when this method is called. 220 | * 221 | * @return The constraint that was added. 222 | */ 223 | - (NSLayoutConstraint *)rztv_pinRightSpaceToSuperviewWithPadding:(CGFloat)padding; 224 | 225 | /** 226 | * Pin all sides of the receiver to its superview's sides with fixed insets. 227 | * 228 | * @param insets Insets between receiver's sides and superview. 229 | * 230 | * @warning The receiver must have a superview when this method is called. 231 | * 232 | * @return The constraints that were added: [top, left, bottom, right] 233 | */ 234 | - (NSArray *)rztv_fillContainerWithInsets:(UIEdgeInsets)insets; 235 | 236 | /** 237 | * Make the receiver fill its superview horizontally with a fixed amount of padding. 238 | * Equivalent to pinning left and right sides to superview. 239 | * 240 | * @param padding The horizontal padding between the receiver and it superview. 241 | * 242 | * @warning The receiver must have a superview when this method is called. 243 | * 244 | * @return The constraints that were added: [left, right] 245 | */ 246 | - (NSArray *)rztv_fillContainerHorizontallyWithPadding:(CGFloat)padding; 247 | 248 | /** 249 | * Make the receiver fill its superview horizontally with a minimum amount of padding. 250 | * Equivalent to pinning left and right sides to superview with relation >=. 251 | * 252 | * @param padding The minimum padding between the receiver and it superview. 253 | * 254 | * @warning The receiver must have a superview when this method is called. 255 | * 256 | * @return The constraints that were added: [left, right] 257 | */ 258 | - (NSArray *)rztv_fillContainerHorizontallyWithMinimumPadding:(CGFloat)padding; 259 | 260 | /** 261 | * Make the receiver fill its superview vertically with a fixed amount of padding. 262 | * Equivalent to pinning top and bottom to superview. 263 | * 264 | * @param padding The vertical padding between the receiver and it superview. 265 | * 266 | * @warning The receiver must have a superview when this method is called. 267 | * 268 | * @return The constraints that were added: [top, bottom] 269 | */ 270 | - (NSArray *)rztv_fillContainerVerticallyWithPadding:(CGFloat)padding; 271 | 272 | /** 273 | * Make the receiver fill its superview vertically with a fixed amount of padding. 274 | * Equivalent to pinning top and bottom to superview with relation >=. 275 | * 276 | * @param padding The vertical padding between the receiver and it superview. 277 | * 278 | * @warning The receiver must have a superview when this method is called. 279 | * 280 | * @return The constraints that were added: [top, bottom] 281 | */ 282 | - (NSArray *)rztv_fillContainerVerticallyWithMinimumPadding:(CGFloat)padding; 283 | 284 | /** 285 | * Center the receiver horizontally in its superview. 286 | * 287 | * @warning The receiver must have a superview when this method is called. 288 | * 289 | * @return The constraint that was added. 290 | */ 291 | - (NSLayoutConstraint *)rztv_centerHorizontallyInContainer; 292 | 293 | /** 294 | * Center the receiver horizontally in its superview with an offset. 295 | * 296 | * @param offset The horizontal offset for the center pinning. Negative = left. 297 | * 298 | * @warning The receiver must have a superview when this method is called. 299 | * 300 | * @return The constraint that was added. 301 | */ 302 | - (NSLayoutConstraint *)rztv_centerHorizontallyInContainerWithOffset:(CGFloat)offset; 303 | 304 | /** 305 | * Center the receiver vertically in its superview. 306 | * 307 | * @warning The receiver must have a superview when this method is called. 308 | * 309 | * @return The constraint that was added. 310 | */ 311 | - (NSLayoutConstraint *)rztv_centerVerticallyInContainer; 312 | 313 | /** 314 | * Center the receiver vertically in its superview with an offset. 315 | * 316 | * @param offset The vertical offset for the center pinning. Negative = up. 317 | * 318 | * @warning The receiver must have a superview when this method is called. 319 | * 320 | * @return The constraint that was added. 321 | */ 322 | - (NSLayoutConstraint *)rztv_centerVerticallyInContainerWithOffset:(CGFloat)offset; 323 | 324 | 325 | /** @name Batch Alignment */ 326 | 327 | /** 328 | * Create a vertical or horizontal minimum space constraint between each adjacent pair of views in an array. 329 | * 330 | * @warning This method is deprecated in favor of @c rztv_spaceSubViews:vertically:itemSpacing:relation: 331 | * 332 | * @param subviews The array of views to space. The order of the array should reflect their spatial order. 333 | * @param vertically @c YES if the spaces should exist between views' top and bottom edges, @c NO if between left and right edges. 334 | * @param itemSpacing The minimum amount of space that should exist between adjacent views. 335 | * 336 | * @return An array of the constraints that were added. 337 | */ 338 | - (NSArray *)rztv_spaceSubviews:(NSArray *)subviews vertically:(BOOL)vertically minimumItemSpacing:(CGFloat)itemSpacing __attribute__((deprecated("Use rztv_spaceSubViews:vertically:itemSpacing:relation: instead."))); 339 | 340 | /** 341 | * Create a vertical or horizontal space constraint between each adjacent pair of views in an array. 342 | * 343 | * @param subviews The array of views to space. The order of the array should reflect their spatial order. 344 | * @param vertically @c YES if the spaces should exist between views' top and bottom edges, @c NO if between left and right edges. 345 | * @param itemSpacing The amount (or minimum/maximum) of space that should exist between adjacent views. 346 | * @param relation Either @c NSLayoutRelationEqual, @c NSLayoutRelationEqualLessThanOrEqual, @c NSLayoutRelationGreaterThanOrEqual. 347 | * 348 | * @return An array of the constraints that were added. 349 | */ 350 | - (NSArray *)rztv_spaceSubviews:(NSArray *)subviews vertically:(BOOL)vertically itemSpacing:(CGFloat)itemSpacing relation:(NSLayoutRelation)relation; 351 | 352 | /** 353 | * Distribute views vertically or horizontally along the same axis with equal spacing in the receiver. 354 | * 355 | * @param subviews Array of subviews to distribute. Must be subviews of the receiver. 356 | * @param vertically @c YES to distribute vertically, @c NO for horizontally 357 | * 358 | * @return An array of the constraints that were added. 359 | */ 360 | - (NSArray *)rztv_distributeSubviews:(NSArray *)subviews vertically:(BOOL)vertically; 361 | 362 | /** 363 | * Align views within the receiver by a particular attribute. 364 | * 365 | * @param subviews An array of views to align. Must be subviews of the receiver. 366 | * @param attribute Attribute by which to align. 367 | * 368 | * @return An array of constraints that were added. 369 | */ 370 | - (NSArray *)rztv_alignSubviews:(NSArray *)subviews byAttribute:(NSLayoutAttribute)attribute; 371 | 372 | @end 373 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZAutoLayoutHelpers.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutHelpers.m 3 | // 4 | // Created by Nick Donaldson on 10/22/13. 5 | 6 | // Copyright 2014 Raizlabs and other contributors 7 | // http://raizlabs.com/ 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import "UIView+RZAutoLayoutHelpers.h" 30 | 31 | @implementation UIView (RZAutoLayoutHelpers) 32 | 33 | # pragma mark - Helpers 34 | 35 | - (BOOL)rztv_constraintIsWithSuperview:(NSLayoutConstraint *)constraint 36 | { 37 | return ((constraint.firstItem == self && constraint.secondItem == self.superview) || 38 | (constraint.firstItem == self.superview && constraint.secondItem == self)); 39 | } 40 | 41 | + (UIView *)rztv_commonAncestorForViews:(NSArray *)views 42 | { 43 | NSParameterAssert([views count] > 0); 44 | 45 | if ( [views count] == 1 ) { 46 | return [views firstObject]; 47 | } 48 | 49 | // First, build a list of view hierarchies, where each element is a list containing the hierarhcy all the way up from each view to the top 50 | NSMutableArray *viewHierarchies = [[NSMutableArray alloc] initWithCapacity:[views count]]; 51 | for ( UIView *view in views ) { 52 | NSMutableArray *viewHierarchy = [NSMutableArray array]; 53 | 54 | UIView *viewCursor = view; 55 | while ( viewCursor != nil ) { 56 | [viewHierarchy addObject:viewCursor]; 57 | viewCursor = [viewCursor superview]; 58 | } 59 | 60 | [viewHierarchies addObject:viewHierarchy]; 61 | } 62 | 63 | // Next, iterate through the view hierarchies. Find the first element that they all have in common. Note that this is n^2, but is quite unlikely this will ever hamper performance because view hierarchies should generally be quite shallow. 64 | UIView *candidateCommonAncestor = nil; 65 | NSArray *firstViewHierarchy = [viewHierarchies firstObject]; 66 | NSArray *otherViewHierarchies = [viewHierarchies subarrayWithRange:NSMakeRange(1, [viewHierarchies count] - 1)]; 67 | 68 | for ( UIView *view in firstViewHierarchy ) { 69 | BOOL commonAncestorMatches = YES; 70 | 71 | for ( NSArray *otherViewHierarchy in otherViewHierarchies ) { 72 | if ( [otherViewHierarchy containsObject:view] == NO ) { 73 | commonAncestorMatches = NO; 74 | break; 75 | } 76 | } 77 | 78 | if ( commonAncestorMatches ) { 79 | candidateCommonAncestor = view; 80 | break; 81 | } 82 | } 83 | 84 | return candidateCommonAncestor; 85 | } 86 | 87 | # pragma mark - Constraint Accessors 88 | 89 | - (NSLayoutConstraint *)rztv_pinnedWidthConstraint 90 | { 91 | __block NSLayoutConstraint *constraint = nil; 92 | [self.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 93 | if (c.firstItem == self && 94 | c.firstAttribute == NSLayoutAttributeWidth && 95 | c.secondAttribute == NSLayoutAttributeNotAnAttribute && 96 | c.relation == NSLayoutRelationEqual) 97 | { 98 | constraint = c; 99 | *stop = YES; 100 | } 101 | }]; 102 | return constraint; 103 | } 104 | 105 | - (NSLayoutConstraint *)rztv_pinnedHeightConstraint 106 | { 107 | __block NSLayoutConstraint *constraint = nil; 108 | [self.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 109 | if (c.firstItem == self && 110 | c.firstAttribute == NSLayoutAttributeHeight && 111 | c.secondAttribute == NSLayoutAttributeNotAnAttribute && 112 | c.relation == NSLayoutRelationEqual) 113 | { 114 | constraint = c; 115 | *stop = YES; 116 | } 117 | }]; 118 | return constraint; 119 | } 120 | 121 | - (NSLayoutConstraint*)rztv_pinnedTopConstraint 122 | { 123 | if (self.superview == nil) return nil; 124 | 125 | __block NSLayoutConstraint *constraint = nil; 126 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 127 | if ([self rztv_constraintIsWithSuperview:c] && 128 | c.firstAttribute == NSLayoutAttributeTop && 129 | c.secondAttribute == NSLayoutAttributeTop && 130 | c.relation == NSLayoutRelationEqual) 131 | { 132 | constraint = c; 133 | *stop = YES; 134 | } 135 | }]; 136 | return constraint; 137 | } 138 | 139 | - (NSLayoutConstraint*)rztv_pinnedLeftConstraint 140 | { 141 | if (self.superview == nil) return nil; 142 | 143 | __block NSLayoutConstraint *constraint = nil; 144 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 145 | if ([self rztv_constraintIsWithSuperview:c] && 146 | (c.firstAttribute == NSLayoutAttributeLeft || c.firstAttribute == NSLayoutAttributeLeading) && 147 | (c.secondAttribute == NSLayoutAttributeLeft || c.secondAttribute == NSLayoutAttributeLeading) && 148 | c.relation == NSLayoutRelationEqual) 149 | { 150 | constraint = c; 151 | *stop = YES; 152 | } 153 | }]; 154 | return constraint; 155 | } 156 | 157 | - (NSLayoutConstraint*)rztv_pinnedRightConstraint 158 | { 159 | if (self.superview == nil) return nil; 160 | 161 | __block NSLayoutConstraint *constraint = nil; 162 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 163 | if ([self rztv_constraintIsWithSuperview:c] && 164 | (c.firstAttribute == NSLayoutAttributeRight || c.firstAttribute == NSLayoutAttributeTrailing) && 165 | (c.secondAttribute == NSLayoutAttributeRight || c.secondAttribute == NSLayoutAttributeTrailing) && 166 | c.relation == NSLayoutRelationEqual) 167 | { 168 | constraint = c; 169 | *stop = YES; 170 | } 171 | }]; 172 | return constraint; 173 | } 174 | 175 | - (NSLayoutConstraint*)rztv_pinnedBottomConstraint 176 | { 177 | if (self.superview == nil) return nil; 178 | 179 | __block NSLayoutConstraint *constraint = nil; 180 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 181 | if ([self rztv_constraintIsWithSuperview:c] && 182 | c.firstAttribute == NSLayoutAttributeBottom && 183 | c.secondAttribute == NSLayoutAttributeBottom && 184 | c.relation == NSLayoutRelationEqual) 185 | { 186 | constraint = c; 187 | *stop = YES; 188 | } 189 | }]; 190 | return constraint; 191 | } 192 | 193 | - (NSLayoutConstraint*)rztv_pinnedCenterXConstraint 194 | { 195 | if (self.superview == nil) return nil; 196 | 197 | __block NSLayoutConstraint *constraint = nil; 198 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 199 | if ((c.firstItem == self && c.firstAttribute == NSLayoutAttributeCenterX) || 200 | (c.secondItem == self && c.secondAttribute == NSLayoutAttributeCenterX)) 201 | { 202 | constraint = c; 203 | *stop = YES; 204 | } 205 | }]; 206 | return constraint; 207 | } 208 | 209 | - (NSLayoutConstraint*)rztv_pinnedCenterYConstraint 210 | { 211 | if (self.superview == nil) return nil; 212 | 213 | __block NSLayoutConstraint *constraint = nil; 214 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 215 | if ((c.firstItem == self && c.firstAttribute == NSLayoutAttributeCenterY) || 216 | (c.secondItem == self && c.secondAttribute == NSLayoutAttributeCenterY)) 217 | { 218 | constraint = c; 219 | *stop = YES; 220 | } 221 | }]; 222 | return constraint; 223 | } 224 | 225 | # pragma mark - Constraint Creation 226 | 227 | - (NSLayoutConstraint *)rztv_pinWidthTo:(CGFloat)width 228 | { 229 | NSLayoutConstraint *w = [NSLayoutConstraint constraintWithItem:self 230 | attribute:NSLayoutAttributeWidth 231 | relatedBy:NSLayoutRelationEqual 232 | toItem:nil 233 | attribute:NSLayoutAttributeNotAnAttribute 234 | multiplier:1.0f 235 | constant:width]; 236 | [self addConstraint:w]; 237 | 238 | return w; 239 | } 240 | 241 | - (NSLayoutConstraint *)rztv_pinWidthToView:(UIView *)view 242 | { 243 | return [self rztv_pinWidthToView:view multiplier:1.0f]; 244 | } 245 | 246 | - (NSLayoutConstraint *)rztv_pinWidthToView:(UIView *)view multiplier:(CGFloat)multiplier 247 | { 248 | NSLayoutConstraint *w = [NSLayoutConstraint constraintWithItem:self 249 | attribute:NSLayoutAttributeWidth 250 | relatedBy:NSLayoutRelationEqual 251 | toItem:view 252 | attribute:NSLayoutAttributeWidth 253 | multiplier:multiplier 254 | constant:0.0f]; 255 | UIView *commonAncestorView = [[self class] rztv_commonAncestorForViews:@[ self, view ]]; 256 | if ( commonAncestorView == nil ) { 257 | NSString *exceptionString = [NSString stringWithFormat:@"Can't find a common ancestor for views: %@ and %@", self, view]; 258 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:exceptionString userInfo:nil]; 259 | } 260 | 261 | [commonAncestorView addConstraint:w]; 262 | 263 | return w; 264 | } 265 | 266 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height 267 | { 268 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 269 | attribute:NSLayoutAttributeHeight 270 | relatedBy:NSLayoutRelationEqual 271 | toItem:nil 272 | attribute:NSLayoutAttributeNotAnAttribute 273 | multiplier:1.0f 274 | constant:height]; 275 | [self addConstraint:h]; 276 | 277 | return h; 278 | } 279 | 280 | - (NSLayoutConstraint *)rztv_pinHeightToView:(UIView *)view 281 | { 282 | return [self rztv_pinHeightToView:view multiplier:1.0f]; 283 | } 284 | 285 | - (NSLayoutConstraint *)rztv_pinHeightToView:(UIView *)view multiplier:(CGFloat)multiplier 286 | { 287 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 288 | attribute:NSLayoutAttributeHeight 289 | relatedBy:NSLayoutRelationEqual 290 | toItem:view 291 | attribute:NSLayoutAttributeHeight 292 | multiplier:multiplier 293 | constant:0.0f]; 294 | UIView *commonAncestorView = [[self class] rztv_commonAncestorForViews:@[ self, view ]]; 295 | if ( commonAncestorView == nil ) { 296 | NSString *exceptionString = [NSString stringWithFormat:@"Can't find a common ancestor for views: %@ and %@", self, view]; 297 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:exceptionString userInfo:nil]; 298 | } 299 | 300 | 301 | [commonAncestorView addConstraint:h]; 302 | 303 | return h; 304 | } 305 | 306 | - (NSArray *)rztv_pinSizeTo:(CGSize)size 307 | { 308 | NSLayoutConstraint *w = [self rztv_pinWidthTo:size.width]; 309 | NSLayoutConstraint *h = [self rztv_pinHeightTo:size.height]; 310 | 311 | return @[w, h]; 312 | } 313 | 314 | - (NSArray *)rztv_fillContainerHorizontallyWithPadding:(CGFloat)padding 315 | { 316 | NSAssert(self.superview != nil, @"Must have superview"); 317 | 318 | NSLayoutConstraint *l = [NSLayoutConstraint constraintWithItem:self 319 | attribute:NSLayoutAttributeLeft 320 | relatedBy:NSLayoutRelationEqual 321 | toItem:self.superview 322 | attribute:NSLayoutAttributeLeft 323 | multiplier:1.0f 324 | constant:padding]; 325 | [self.superview addConstraint:l]; 326 | 327 | NSLayoutConstraint *r = [NSLayoutConstraint constraintWithItem:self 328 | attribute:NSLayoutAttributeRight 329 | relatedBy:NSLayoutRelationEqual 330 | toItem:self.superview 331 | attribute:NSLayoutAttributeRight 332 | multiplier:1.0f 333 | constant:-padding]; 334 | [self.superview addConstraint:r]; 335 | 336 | return @[l, r]; 337 | } 338 | 339 | - (NSArray *)rztv_fillContainerHorizontallyWithMinimumPadding:(CGFloat)padding 340 | { 341 | NSAssert(self.superview != nil, @"Must have superview"); 342 | 343 | NSLayoutConstraint *l = [NSLayoutConstraint constraintWithItem:self 344 | attribute:NSLayoutAttributeLeft 345 | relatedBy:NSLayoutRelationGreaterThanOrEqual 346 | toItem:self.superview 347 | attribute:NSLayoutAttributeLeft 348 | multiplier:1.0f 349 | constant:padding]; 350 | [self.superview addConstraint:l]; 351 | 352 | NSLayoutConstraint *r = [NSLayoutConstraint constraintWithItem:self 353 | attribute:NSLayoutAttributeRight 354 | relatedBy:NSLayoutRelationLessThanOrEqual 355 | toItem:self.superview 356 | attribute:NSLayoutAttributeRight 357 | multiplier:1.0f 358 | constant:-padding]; 359 | [self.superview addConstraint:r]; 360 | 361 | return @[l, r]; 362 | } 363 | 364 | - (NSArray *)rztv_fillContainerVerticallyWithPadding:(CGFloat)padding 365 | { 366 | NSAssert(self.superview != nil, @"Must have superview"); 367 | 368 | NSLayoutConstraint *t = [NSLayoutConstraint constraintWithItem:self 369 | attribute:NSLayoutAttributeTop 370 | relatedBy:NSLayoutRelationEqual 371 | toItem:self.superview 372 | attribute:NSLayoutAttributeTop 373 | multiplier:1.0f 374 | constant:padding]; 375 | [self.superview addConstraint:t]; 376 | 377 | NSLayoutConstraint *b = [NSLayoutConstraint constraintWithItem:self 378 | attribute:NSLayoutAttributeBottom 379 | relatedBy:NSLayoutRelationEqual 380 | toItem:self.superview 381 | attribute:NSLayoutAttributeBottom 382 | multiplier:1.0f 383 | constant:-padding]; 384 | [self.superview addConstraint:b]; 385 | 386 | return @[t, b]; 387 | } 388 | 389 | - (NSArray *)rztv_fillContainerVerticallyWithMinimumPadding:(CGFloat)padding 390 | { 391 | NSAssert(self.superview != nil, @"Must have superview"); 392 | 393 | NSLayoutConstraint *t = [NSLayoutConstraint constraintWithItem:self 394 | attribute:NSLayoutAttributeTop 395 | relatedBy:NSLayoutRelationGreaterThanOrEqual 396 | toItem:self.superview 397 | attribute:NSLayoutAttributeTop 398 | multiplier:1.0f 399 | constant:padding]; 400 | [self.superview addConstraint:t]; 401 | 402 | NSLayoutConstraint *b = [NSLayoutConstraint constraintWithItem:self 403 | attribute:NSLayoutAttributeBottom 404 | relatedBy:NSLayoutRelationLessThanOrEqual 405 | toItem:self.superview 406 | attribute:NSLayoutAttributeBottom 407 | multiplier:1.0f 408 | constant:-padding]; 409 | [self.superview addConstraint:b]; 410 | 411 | return @[t, b]; 412 | } 413 | 414 | - (NSLayoutConstraint *)rztv_pinTopSpaceToSuperviewWithPadding:(CGFloat)padding 415 | { 416 | NSAssert(self.superview != nil, @"Must have superview"); 417 | 418 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 419 | attribute:NSLayoutAttributeTop 420 | relatedBy:NSLayoutRelationEqual 421 | toItem:self.superview 422 | attribute:NSLayoutAttributeTop 423 | multiplier:1.0f 424 | constant:padding]; 425 | [self.superview addConstraint:c]; 426 | 427 | return c; 428 | } 429 | 430 | 431 | - (NSLayoutConstraint *)rztv_pinLeftSpaceToSuperviewWithPadding:(CGFloat)padding 432 | { 433 | NSAssert(self.superview != nil, @"Must have superview"); 434 | 435 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 436 | attribute:NSLayoutAttributeLeft 437 | relatedBy:NSLayoutRelationEqual 438 | toItem:self.superview 439 | attribute:NSLayoutAttributeLeft 440 | multiplier:1.0f 441 | constant:padding]; 442 | [self.superview addConstraint:c]; 443 | 444 | return c; 445 | } 446 | 447 | - (NSLayoutConstraint *)rztv_pinBottomSpaceToSuperviewWithPadding:(CGFloat)padding 448 | { 449 | NSAssert(self.superview != nil, @"Must have superview"); 450 | 451 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 452 | attribute:NSLayoutAttributeBottom 453 | relatedBy:NSLayoutRelationEqual 454 | toItem:self.superview 455 | attribute:NSLayoutAttributeBottom 456 | multiplier:1.0f 457 | constant:-padding]; 458 | [self.superview addConstraint:c]; 459 | 460 | return c; 461 | } 462 | 463 | - (NSLayoutConstraint *)rztv_pinRightSpaceToSuperviewWithPadding:(CGFloat)padding 464 | { 465 | NSAssert(self.superview != nil, @"Must have superview"); 466 | 467 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 468 | attribute:NSLayoutAttributeRight 469 | relatedBy:NSLayoutRelationEqual 470 | toItem:self.superview 471 | attribute:NSLayoutAttributeRight 472 | multiplier:1.0f 473 | constant:-padding]; 474 | [self.superview addConstraint:c]; 475 | 476 | return c; 477 | } 478 | 479 | 480 | - (NSLayoutConstraint *)rztv_centerHorizontallyInContainer 481 | { 482 | return [self rztv_centerHorizontallyInContainerWithOffset:0]; 483 | } 484 | 485 | - (NSLayoutConstraint *)rztv_centerHorizontallyInContainerWithOffset:(CGFloat)offset 486 | { 487 | NSAssert(self.superview != nil, @"Must have superview"); 488 | 489 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 490 | attribute:NSLayoutAttributeCenterX 491 | relatedBy:NSLayoutRelationEqual 492 | toItem:self.superview 493 | attribute:NSLayoutAttributeCenterX 494 | multiplier:1.0f 495 | constant:offset]; 496 | [self.superview addConstraint:c]; 497 | 498 | return c; 499 | } 500 | 501 | - (NSLayoutConstraint *)rztv_centerVerticallyInContainer 502 | { 503 | return [self rztv_centerVerticallyInContainerWithOffset:0]; 504 | } 505 | 506 | - (NSLayoutConstraint *)rztv_centerVerticallyInContainerWithOffset:(CGFloat)offset 507 | { 508 | NSAssert(self.superview != nil, @"Must have superview"); 509 | 510 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 511 | attribute:NSLayoutAttributeCenterY 512 | relatedBy:NSLayoutRelationEqual 513 | toItem:self.superview 514 | attribute:NSLayoutAttributeCenterY 515 | multiplier:1.0f 516 | constant:offset]; 517 | [self.superview addConstraint:c]; 518 | 519 | return c; 520 | } 521 | 522 | - (NSArray *)rztv_fillContainerWithInsets:(UIEdgeInsets)insets 523 | { 524 | NSAssert(self.superview != nil, @"Must have superview"); 525 | 526 | NSLayoutConstraint *top = [self rztv_pinTopSpaceToSuperviewWithPadding:insets.top]; 527 | NSLayoutConstraint *left = [self rztv_pinLeftSpaceToSuperviewWithPadding:insets.left]; 528 | NSLayoutConstraint *bottom = [self rztv_pinBottomSpaceToSuperviewWithPadding:insets.bottom]; 529 | NSLayoutConstraint *right = [self rztv_pinRightSpaceToSuperviewWithPadding:insets.right]; 530 | 531 | NSArray *constraints = @[top, left, bottom, right]; 532 | 533 | [self.superview addConstraints:constraints]; 534 | 535 | return constraints; 536 | } 537 | 538 | # pragma mark - Batch Alignment 539 | 540 | - (NSArray *)rztv_spaceSubviews:(NSArray *)subviews vertically:(BOOL)vertically minimumItemSpacing:(CGFloat)itemSpacing 541 | { 542 | return [self rztv_spaceSubviews:subviews vertically:vertically itemSpacing:itemSpacing relation:NSLayoutRelationGreaterThanOrEqual]; 543 | } 544 | 545 | - (NSArray *)rztv_spaceSubviews:(NSArray *)subviews vertically:(BOOL)vertically itemSpacing:(CGFloat)itemSpacing relation:(NSLayoutRelation)relation 546 | { 547 | NSAssert(subviews.count > 1, @"Must provide at least two items"); 548 | 549 | NSMutableArray *constraints = [NSMutableArray array]; 550 | 551 | NSLayoutAttribute a1 = vertically ? NSLayoutAttributeTop : NSLayoutAttributeLeft; 552 | NSLayoutAttribute a2 = vertically ? NSLayoutAttributeBottom : NSLayoutAttributeRight; 553 | 554 | [subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) 555 | { 556 | 557 | UIView *nextView = (idx == subviews.count - 1) ? nil : subviews[idx + 1]; 558 | 559 | if (nextView) 560 | { 561 | NSLayoutConstraint *s = [NSLayoutConstraint constraintWithItem:nextView 562 | attribute:a1 563 | relatedBy:relation 564 | toItem:view 565 | attribute:a2 566 | multiplier:1.0f 567 | constant:itemSpacing]; 568 | 569 | [constraints addObject:s]; 570 | } 571 | 572 | }]; 573 | 574 | [self addConstraints:constraints]; 575 | 576 | return constraints; 577 | } 578 | 579 | - (NSArray *)rztv_distributeSubviews:(NSArray *)subviews vertically:(BOOL)vertically 580 | { 581 | NSAssert(subviews.count > 1, @"Must provide at least two items"); 582 | 583 | NSMutableArray *constraints = [NSMutableArray array]; 584 | 585 | NSLayoutAttribute centerAlongAxisAttribute = vertically ? NSLayoutAttributeCenterX : NSLayoutAttributeCenterY; 586 | NSLayoutAttribute distributeAlongAxisAttribute = vertically ? NSLayoutAttributeCenterY : NSLayoutAttributeCenterX; 587 | 588 | // Calculate the incremental offset of each view as proportion of the container's center point: 1/((n + 1) / 2) 589 | CGFloat distributionMultiplierIncrement = 1.0f / ((subviews.count + 1) / 2.0f); 590 | 591 | [subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) 592 | { 593 | // Calculate the actual multiplier for this view index. 594 | CGFloat distributionMultiplier = distributionMultiplierIncrement * (idx + 1); 595 | 596 | // Create a constraint representing distribution along the given axis using this multiplier. 597 | NSLayoutConstraint *distributeConstraint = [NSLayoutConstraint constraintWithItem:view 598 | attribute:distributeAlongAxisAttribute 599 | relatedBy:NSLayoutRelationEqual 600 | toItem:self 601 | attribute:distributeAlongAxisAttribute 602 | multiplier:distributionMultiplier 603 | constant:0.0f]; 604 | 605 | // Create a constraint to center the view along the other axis. 606 | NSLayoutConstraint *centerConstraint = [NSLayoutConstraint constraintWithItem:view 607 | attribute:centerAlongAxisAttribute 608 | relatedBy:NSLayoutRelationEqual 609 | toItem:self 610 | attribute:centerAlongAxisAttribute 611 | multiplier:1.0f 612 | constant:0.0f]; 613 | // Add both constraints for the view. 614 | [constraints addObject:distributeConstraint]; 615 | [constraints addObject:centerConstraint]; 616 | }]; 617 | 618 | [self addConstraints:constraints]; 619 | 620 | return constraints; 621 | } 622 | 623 | - (NSArray *)rztv_alignSubviews:(NSArray *)subviews byAttribute:(NSLayoutAttribute)attribute 624 | { 625 | NSAssert(subviews.count > 1, @"Must provide at least two items"); 626 | 627 | NSMutableArray *constraints = [NSMutableArray array]; 628 | 629 | [subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) 630 | { 631 | 632 | UIView *nextView = (idx == subviews.count - 1) ? nil : subviews[idx + 1]; 633 | if (nextView) 634 | { 635 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:nextView 636 | attribute:attribute 637 | relatedBy:NSLayoutRelationEqual 638 | toItem:view 639 | attribute:attribute 640 | multiplier:1.0f 641 | constant:0.0f]; 642 | [constraints addObject:c]; 643 | } 644 | 645 | }]; 646 | 647 | [self addConstraints:constraints]; 648 | 649 | return constraints; 650 | } 651 | 652 | @end 653 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZBorders.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZBorders.h 3 | // Raizlabs 4 | // 5 | // Created by Nick Donaldson on 10/30/13. 6 | 7 | // Copyright 2014 Raizlabs and other contributors 8 | // http://raizlabs.com/ 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | typedef NS_ENUM(NSUInteger, RZViewBorderMask) 33 | { 34 | RZViewBorderNone = 0, 35 | RZViewBorderLeft = (1 << 0), 36 | RZViewBorderBottom = (1 << 1), 37 | RZViewBorderRight = (1 << 2), 38 | RZViewBorderTop = (1 << 3), 39 | RZViewBorderAll = RZViewBorderLeft | RZViewBorderBottom | RZViewBorderRight | RZViewBorderTop 40 | }; 41 | 42 | // Adds a generated border image view as the highest z-ordered subview of the target view (above all other views). 43 | @interface UIView (RZBorders) 44 | 45 | - (void)rztv_addBordersWithCornerRadius:(CGFloat)radius width:(CGFloat)borderWidth color:(UIColor*)color; 46 | - (void)rztv_addBordersWithMask:(RZViewBorderMask)mask width:(CGFloat)borderWidth color:(UIColor*)color; 47 | - (void)rztv_removeBorders; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZBorders.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZBorders.m 3 | // Raizlabs 4 | // 5 | // Created by Nick Donaldson on 10/30/13. 6 | 7 | // Copyright 2014 Raizlabs and other contributors 8 | // http://raizlabs.com/ 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "UIView+RZBorders.h" 31 | #import 32 | #import 33 | 34 | static char kRZBorderViewKey; 35 | 36 | @interface RZBorderedImageView : UIImageView 37 | 38 | + (NSMutableDictionary *)maskingImageCache; 39 | + (NSMutableDictionary *)coloredBorderImageCache; 40 | 41 | - (void)setBorderMask:(RZViewBorderMask)mask width:(CGFloat)width color:(UIColor *)color; 42 | - (void)setBorderCornerRadius:(CGFloat)radius width:(CGFloat)width color:(UIColor *)color; 43 | 44 | // Returns a new or cached masking image that can be used to fill a rect area to produce a bordered effect. 45 | - (UIImage *)maskingImageForMask:(RZViewBorderMask)mask width:(CGFloat)width; 46 | 47 | // Returns a new or cached masking image that can be used to fill a rect area to produce a pill effect. 48 | - (UIImage *)maskingImageForCornerRadius:(CGFloat)radius width:(CGFloat)width; 49 | 50 | // Returns a clear, stretchable image with the specified borders, width, and color 51 | - (UIImage *)coloredBorderImageWithMask:(RZViewBorderMask)mask width:(CGFloat)width color:(UIColor *)color; 52 | 53 | // Returns a clear, stretchable image with the specified corner radius, width, and color 54 | - (UIImage *)coloredBorderImageWithCornerRadius:(CGFloat)radius width:(CGFloat)width color:(UIColor *)color; 55 | 56 | @end 57 | 58 | // --------------------------------------- 59 | 60 | @implementation UIView (RZBorders) 61 | 62 | - (RZBorderedImageView *)rztv_borderImgView 63 | { 64 | return objc_getAssociatedObject(self, &kRZBorderViewKey); 65 | } 66 | 67 | - (void)rztv_addBordersWithMask:(RZViewBorderMask)mask width:(CGFloat)borderWidth color:(UIColor *)color 68 | { 69 | RZBorderedImageView *imgView = objc_getAssociatedObject(self, &kRZBorderViewKey); 70 | if (imgView == nil) 71 | { 72 | CGRect frame = {.origin = CGPointZero, .size = self.bounds.size}; 73 | imgView = [[RZBorderedImageView alloc] initWithFrame:frame]; 74 | imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 75 | [imgView setBorderMask:mask width:borderWidth color:color]; 76 | [self addSubview:imgView]; 77 | objc_setAssociatedObject(self, &kRZBorderViewKey, imgView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 78 | } 79 | 80 | imgView.backgroundColor = [UIColor clearColor]; 81 | imgView.opaque = NO; 82 | } 83 | 84 | - (void)rztv_addBordersWithCornerRadius:(CGFloat)radius width:(CGFloat)borderWidth color:(UIColor *)color 85 | { 86 | RZBorderedImageView *imgView = objc_getAssociatedObject(self, &kRZBorderViewKey); 87 | if (imgView == nil) 88 | { 89 | imgView = [[RZBorderedImageView alloc] initWithFrame:self.bounds]; 90 | imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 91 | [imgView setBorderCornerRadius:radius width:borderWidth color:color]; 92 | [self addSubview:imgView]; 93 | objc_setAssociatedObject(self, &kRZBorderViewKey, imgView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 94 | } 95 | 96 | imgView.backgroundColor = [UIColor clearColor]; 97 | imgView.opaque = NO; 98 | } 99 | 100 | - (void)rztv_removeBorders 101 | { 102 | RZBorderedImageView *imgView = objc_getAssociatedObject(self, &kRZBorderViewKey); 103 | if (imgView) 104 | { 105 | [imgView removeFromSuperview]; 106 | objc_setAssociatedObject(self, &kRZBorderViewKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 107 | } 108 | } 109 | 110 | @end 111 | 112 | // --------------------------------------- 113 | 114 | @implementation RZBorderedImageView 115 | 116 | - (id)initWithFrame:(CGRect)frame 117 | { 118 | self = [super initWithFrame:frame]; 119 | if (self) 120 | { 121 | self.userInteractionEnabled = NO; 122 | self.contentScaleFactor = [[UIScreen mainScreen] scale]; 123 | } 124 | return self; 125 | } 126 | 127 | - (void)layoutSubviews 128 | { 129 | [super layoutSubviews]; 130 | 131 | // always keep me at the front 132 | self.frame = self.superview.bounds; 133 | [self.superview bringSubviewToFront:self]; 134 | } 135 | 136 | #pragma mark - Public 137 | 138 | - (void)setBorderMask:(RZViewBorderMask)mask width:(CGFloat)width color:(UIColor *)color 139 | { 140 | self.image = [self coloredBorderImageWithMask:mask width:width color:color]; 141 | } 142 | 143 | - (void)setBorderCornerRadius:(CGFloat)radius width:(CGFloat)width color:(UIColor *)color 144 | { 145 | self.image = [self coloredBorderImageWithCornerRadius:radius width:width color:color]; 146 | } 147 | 148 | #pragma mark - Caches 149 | 150 | + (NSMutableDictionary *)maskingImageCache 151 | { 152 | static NSMutableDictionary *s_maskCache = nil; 153 | static dispatch_once_t onceToken; 154 | dispatch_once(&onceToken, ^{ 155 | s_maskCache = [NSMutableDictionary dictionary]; 156 | }); 157 | return s_maskCache; 158 | } 159 | 160 | + (NSMutableDictionary *)coloredBorderImageCache 161 | { 162 | static NSMutableDictionary * s_cbiCache = nil; 163 | static dispatch_once_t onceToken; 164 | dispatch_once(&onceToken, ^{ 165 | 166 | s_cbiCache = [NSMutableDictionary dictionary]; 167 | 168 | // Automatically clear the cache in low-memory situations. Should be a rare occurrence. 169 | // This notification observation will be valid for the application lifetime - no need to ever remove the observer. 170 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:nil usingBlock:^(NSNotification *note) { 171 | [[[RZBorderedImageView class] maskingImageCache] removeAllObjects]; 172 | [[[RZBorderedImageView class] coloredBorderImageCache] removeAllObjects]; 173 | }]; 174 | 175 | }); 176 | return s_cbiCache; 177 | } 178 | 179 | #pragma mark - Bitmap generation 180 | 181 | - (UIImage *)maskingImageForMask:(RZViewBorderMask)mask width:(CGFloat)width 182 | { 183 | // must round the width to nearest pixel for current screen scale 184 | CGFloat scale = [[UIScreen mainScreen] scale]; 185 | width = round(width * scale) / scale; 186 | 187 | NSString *cacheKey = [NSString stringWithFormat:@"%lu_%.2f", (unsigned long)mask, width]; 188 | UIImage *maskImage = [[[self class] maskingImageCache] objectForKey:cacheKey]; 189 | if (maskImage == nil) 190 | { 191 | CGFloat imgDim = ceilf(width * 3); 192 | CGSize imgSize = CGSizeMake(imgDim, imgDim); 193 | 194 | UIGraphicsBeginImageContextWithOptions(imgSize, NO, [[UIScreen mainScreen] scale]); 195 | 196 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 197 | 198 | CGRect fullRect = (CGRect){CGPointZero, imgSize}; 199 | CGContextClearRect(ctx, fullRect); 200 | 201 | CGColorRef maskImageColorRef = [[UIColor whiteColor] CGColor]; 202 | 203 | CGContextSetStrokeColorWithColor(ctx, maskImageColorRef); 204 | CGContextSetLineWidth(ctx, width); 205 | 206 | CGPoint segArray[8]; 207 | NSUInteger segCount = 0; 208 | 209 | CGFloat midWidth = width * 0.5; 210 | 211 | if (mask & RZViewBorderLeft) 212 | { 213 | CGPoint start = CGPointMake(midWidth, 0); 214 | CGPoint end = CGPointMake(midWidth, imgDim); 215 | segArray[segCount++] = start; 216 | segArray[segCount++] = end; 217 | } 218 | 219 | if (mask & RZViewBorderTop) 220 | { 221 | CGPoint start = CGPointMake(0, imgDim - midWidth); 222 | CGPoint end = CGPointMake(imgDim, imgDim - midWidth); 223 | segArray[segCount++] = start; 224 | segArray[segCount++] = end; 225 | } 226 | 227 | if (mask & RZViewBorderRight) 228 | { 229 | CGPoint start = CGPointMake(imgDim - midWidth, imgDim); 230 | CGPoint end = CGPointMake(imgDim - midWidth, 0); 231 | segArray[segCount++] = start; 232 | segArray[segCount++] = end; 233 | } 234 | 235 | if (mask & RZViewBorderBottom) 236 | { 237 | CGPoint start = CGPointMake(imgDim, midWidth); 238 | CGPoint end = CGPointMake(0, midWidth); 239 | segArray[segCount++] = start; 240 | segArray[segCount++] = end; 241 | } 242 | 243 | CGContextStrokeLineSegments(ctx, segArray, segCount); 244 | 245 | maskImage = UIGraphicsGetImageFromCurrentImageContext(); 246 | 247 | if (maskImage) 248 | { 249 | [[[self class] maskingImageCache] setObject:maskImage forKey:cacheKey]; 250 | } 251 | 252 | UIGraphicsEndImageContext(); 253 | } 254 | 255 | return maskImage; 256 | } 257 | 258 | - (UIImage *)maskingImageForCornerRadius:(CGFloat)radius width:(CGFloat)width 259 | { 260 | // must round the width to nearest pixel for current screen scale 261 | CGFloat scale = [[UIScreen mainScreen] scale]; 262 | width = round(width * scale) / scale; 263 | 264 | NSString *cacheKey = [NSString stringWithFormat:@"%.2f_%.2f", radius, width]; 265 | UIImage *maskImage = [[[self class] maskingImageCache] objectForKey:cacheKey]; 266 | if (maskImage == nil) 267 | { 268 | CGFloat imgDim = ceilf((width * 3) + (radius * 2)); 269 | CGSize imgSize = CGSizeMake(imgDim, imgDim); 270 | 271 | UIGraphicsBeginImageContextWithOptions(imgSize, NO, 0); 272 | 273 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 274 | 275 | CGRect fullRect = (CGRect){CGPointZero, imgSize}; 276 | CGContextClearRect(ctx, fullRect); 277 | 278 | CGColorRef maskImageColorRef = [[UIColor whiteColor] CGColor]; 279 | 280 | CGContextSetStrokeColorWithColor(ctx, maskImageColorRef); 281 | CGContextSetLineWidth(ctx, width); 282 | 283 | CGRect roundedRectFrame = CGRectInset(fullRect, width / 2, width / 2); 284 | CGPathRef roundedRectPath = CGPathCreateWithRoundedRect(roundedRectFrame, radius, radius, NULL); 285 | CGContextAddPath(ctx, roundedRectPath); 286 | CGContextStrokePath(ctx); 287 | CGPathRelease(roundedRectPath); 288 | 289 | maskImage = UIGraphicsGetImageFromCurrentImageContext(); 290 | 291 | if (maskImage) 292 | { 293 | [[[self class] maskingImageCache] setObject:maskImage forKey:cacheKey]; 294 | } 295 | 296 | UIGraphicsEndImageContext(); 297 | } 298 | 299 | return maskImage; 300 | } 301 | 302 | 303 | - (UIImage *)coloredBorderImageWithMask:(RZViewBorderMask)mask width:(CGFloat)width color:(UIColor *)color 304 | { 305 | CGFloat r, g, b, a; 306 | [color getRed:&r green:&g blue:&b alpha:&a]; 307 | NSString *cacheKey = [NSString stringWithFormat:@"%lu_%.2f-%lu_%lu_%lu_%lu", 308 | (unsigned long)mask, 309 | width, 310 | (unsigned long)(r * 255), 311 | (unsigned long)(g * 255), 312 | (unsigned long)(b * 255), 313 | (unsigned long)(a * 255)]; 314 | 315 | UIImage *borderImage = [[[self class] coloredBorderImageCache] objectForKey:cacheKey]; 316 | if (borderImage == nil) 317 | { 318 | UIImage *maskImage = [self maskingImageForMask:mask width:width]; 319 | borderImage = [self borderImageWithMaskImage:maskImage color:color]; 320 | 321 | if (borderImage) 322 | { 323 | [[[self class] coloredBorderImageCache] setObject:borderImage forKey:cacheKey]; 324 | } 325 | } 326 | 327 | return borderImage; 328 | } 329 | 330 | - (UIImage *)coloredBorderImageWithCornerRadius:(CGFloat)radius width:(CGFloat)width color:(UIColor *)color 331 | { 332 | CGFloat r, g, b, a; 333 | [color getRed:&r green:&g blue:&b alpha:&a]; 334 | NSString *cacheKey = [NSString stringWithFormat:@"%.2f_%.2f-%lu_%lu_%lu_%lu", 335 | radius, 336 | width, 337 | (unsigned long)(r * 255), 338 | (unsigned long)(g * 255), 339 | (unsigned long)(b * 255), 340 | (unsigned long)(a * 255)]; 341 | 342 | UIImage *borderImage = [[[self class] coloredBorderImageCache] objectForKey:cacheKey]; 343 | if (borderImage == nil) 344 | { 345 | UIImage *maskImage = [self maskingImageForCornerRadius:radius width:width]; 346 | borderImage = [self borderImageWithMaskImage:maskImage color:color]; 347 | 348 | if (borderImage) 349 | { 350 | [[[self class] coloredBorderImageCache] setObject:borderImage forKey:cacheKey]; 351 | } 352 | } 353 | 354 | return borderImage; 355 | } 356 | 357 | - (UIImage *)borderImageWithMaskImage:(UIImage *)maskImage color:(UIColor *)color 358 | { 359 | UIImage *borderImage = nil; 360 | 361 | if (maskImage) 362 | { 363 | CGSize imgSize = maskImage.size; 364 | 365 | UIGraphicsBeginImageContextWithOptions(imgSize, NO, [[UIScreen mainScreen] scale]); 366 | 367 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 368 | 369 | CGRect fullRect = (CGRect){CGPointZero, imgSize}; 370 | 371 | // draw color border 372 | CGContextSetFillColorWithColor(ctx, [color CGColor]); 373 | CGContextFillRect(ctx, fullRect); 374 | 375 | // mask it out 376 | CGContextSetBlendMode(ctx, kCGBlendModeDestinationIn); 377 | CGContextDrawImage(ctx, fullRect, [maskImage CGImage]); 378 | 379 | UIEdgeInsets stretchInsets = UIEdgeInsetsMake(floor(imgSize.height * 0.5), floor(imgSize.width * 0.5), floor(imgSize.height * 0.5), floor(imgSize.width * 0.5)); 380 | 381 | borderImage = [UIGraphicsGetImageFromCurrentImageContext() resizableImageWithCapInsets:stretchInsets 382 | resizingMode:UIImageResizingModeStretch]; 383 | UIGraphicsEndImageContext(); 384 | } 385 | 386 | return borderImage; 387 | } 388 | 389 | @end 390 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZFrameUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZFrameUtils.h 3 | // 4 | // Created by Nick Donaldson on 3/27/13. 5 | 6 | // Copyright 2014 Raizlabs and other contributors 7 | // http://raizlabs.com/ 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | // For easy setting of frame values 32 | 33 | @interface UIView (RZFrameUtils) 34 | 35 | - (void)rztv_setFrameOriginX:(CGFloat)originX; 36 | - (void)rztv_setFrameOriginX:(CGFloat)originX lockRight:(BOOL)lockRight; 37 | - (void)rztv_setFrameOriginY:(CGFloat)originY; 38 | - (void)rztv_setFrameOriginY:(CGFloat)originY lockBottom:(BOOL)lockBottom; 39 | - (void)rztv_setFrameOrigin:(CGPoint)point; 40 | 41 | - (void)rztv_setFrameWidth:(CGFloat)width; 42 | - (void)rztv_setFrameWidth:(CGFloat)width alignRight:(BOOL)alignRight; 43 | - (void)rztv_setFrameHeight:(CGFloat)height; 44 | - (void)rztv_setFrameSize:(CGSize)size; 45 | 46 | // "nudge" by an amount - add that amount to each frame property 47 | - (void)rztv_nudgeFrameOriginX:(CGFloat)nx originY:(CGFloat)ny width:(CGFloat)nw height:(CGFloat)nh; 48 | - (void)rztv_moveFrameToTheRightOf:(CGRect)leftFrame withPadding:(int)padding; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Example/Pods/RZUtils/RZUtils/Categories/UIView/UIView+RZFrameUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZFrameUtils.m 3 | // 4 | // Created by Nick Donaldson on 3/27/13. 5 | 6 | // Copyright 2014 Raizlabs and other contributors 7 | // http://raizlabs.com/ 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import "UIView+RZFrameUtils.h" 30 | 31 | 32 | @implementation UIView (RZFrameUtils) 33 | 34 | - (void)rztv_setFrameOriginX:(CGFloat)originX 35 | { 36 | [self rztv_setFrameOriginX:originX lockRight:NO]; 37 | } 38 | 39 | - (void)rztv_setFrameOriginX:(CGFloat)originX lockRight:(BOOL)lockRight 40 | { 41 | CGFloat rightEdge = CGRectGetMaxX(self.frame); 42 | [self rztv_setFrameOrigin:CGPointMake(originX, self.frame.origin.y)]; 43 | if (lockRight){ 44 | [self rztv_setFrameWidth:rightEdge - originX]; 45 | } 46 | } 47 | 48 | - (void)rztv_setFrameOriginY:(CGFloat)originY 49 | { 50 | [self rztv_setFrameOriginY:originY lockBottom:NO]; 51 | } 52 | 53 | - (void)rztv_setFrameOriginY:(CGFloat)originY lockBottom:(BOOL)lockBottom 54 | { 55 | CGFloat bottomEdge = CGRectGetMaxY(self.frame); 56 | [self rztv_setFrameOrigin:CGPointMake(self.frame.origin.x, originY)]; 57 | if (lockBottom) 58 | { 59 | [self rztv_setFrameHeight:bottomEdge - originY]; 60 | } 61 | } 62 | 63 | - (void)rztv_setFrameOrigin:(CGPoint)point 64 | { 65 | CGRect frame = self.frame; 66 | frame.origin = point; 67 | self.frame = frame; 68 | } 69 | 70 | - (void)rztv_setFrameWidth:(CGFloat)width 71 | { 72 | [self rztv_setFrameWidth:width alignRight:NO]; 73 | } 74 | 75 | - (void)rztv_setFrameWidth:(CGFloat)width alignRight:(BOOL)alignRight 76 | { 77 | if (alignRight){ 78 | CGFloat rightX = CGRectGetMaxX(self.frame); 79 | [self rztv_setFrameSize:CGSizeMake(width, self.frame.size.height)]; 80 | [self rztv_setFrameOriginX:rightX-width]; 81 | } 82 | else{ 83 | [self rztv_setFrameSize:CGSizeMake(width, self.frame.size.height)]; 84 | } 85 | } 86 | 87 | - (void)rztv_setFrameHeight:(CGFloat)height 88 | { 89 | [self rztv_setFrameSize:CGSizeMake(self.frame.size.width, height)]; 90 | } 91 | 92 | - (void)rztv_setFrameSize:(CGSize)size 93 | { 94 | CGRect frame = self.frame; 95 | frame.size = size; 96 | self.frame = frame; 97 | } 98 | 99 | - (void)rztv_nudgeFrameOriginX:(CGFloat)nx originY:(CGFloat)ny width:(CGFloat)nw height:(CGFloat)nh 100 | { 101 | CGRect frame = self.frame; 102 | frame.origin.x += nx; 103 | frame.origin.y += ny; 104 | frame.size.width += nw; 105 | frame.size.height += nh; 106 | self.frame = frame; 107 | } 108 | 109 | - (void)rztv_moveFrameToTheRightOf:(CGRect)leftFrame withPadding:(int)padding 110 | { 111 | self.frame = CGRectMake(leftFrame.origin.x + leftFrame.size.width + padding, 112 | self.frame.origin.y, 113 | self.frame.size.width, 114 | self.frame.size.height); 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = -ObjC 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RZIntrinsicContentSizeTextView_RZIntrinsicContentSizeTextView : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RZIntrinsicContentSizeTextView_RZIntrinsicContentSizeTextView 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-RZIntrinsicContentSizeTextView-environment.h" 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView.xcconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/RZIntrinsicContentSizeTextView/094deef4260f44453620fc9747ece191ad7ba056/Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView.xcconfig -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZUtils/Pods-RZIntrinsicContentSizeTextView-RZUtils-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-RZIntrinsicContentSizeTextView-RZUtils.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/RZUtils" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = ${PODS_RZINTRINSICCONTENTSIZETEXTVIEW_RZUTILS_OTHER_LDFLAGS} -ObjC 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZUtils/Pods-RZIntrinsicContentSizeTextView-RZUtils-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RZIntrinsicContentSizeTextView_RZUtils : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RZIntrinsicContentSizeTextView_RZUtils 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZUtils/Pods-RZIntrinsicContentSizeTextView-RZUtils-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-RZIntrinsicContentSizeTextView-environment.h" 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView-RZUtils/Pods-RZIntrinsicContentSizeTextView-RZUtils.xcconfig: -------------------------------------------------------------------------------- 1 | PODS_RZINTRINSICCONTENTSIZETEXTVIEW_RZUTILS_OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RZIntrinsicContentSizeTextView 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2015 Raizlabs 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | 29 | ## RZUtils 30 | 31 | Copyright 2014 Raizlabs and other contributors 32 | http://raizlabs.com/ 33 | 34 | Permission is hereby granted, free of charge, to any person obtaining 35 | a copy of this software and associated documentation files (the 36 | "Software"), to deal in the Software without restriction, including 37 | without limitation the rights to use, copy, modify, merge, publish, 38 | distribute, sublicense, and/or sell copies of the Software, and to 39 | permit persons to whom the Software is furnished to do so, subject to 40 | the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be 43 | included in all copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 47 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 49 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 50 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 51 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 52 | 53 | Generated by CocoaPods - http://cocoapods.org 54 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2015 Raizlabs 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | Title 40 | RZIntrinsicContentSizeTextView 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright 2014 Raizlabs and other contributors 47 | http://raizlabs.com/ 48 | 49 | Permission is hereby granted, free of charge, to any person obtaining 50 | a copy of this software and associated documentation files (the 51 | "Software"), to deal in the Software without restriction, including 52 | without limitation the rights to use, copy, modify, merge, publish, 53 | distribute, sublicense, and/or sell copies of the Software, and to 54 | permit persons to whom the Software is furnished to do so, subject to 55 | the following conditions: 56 | 57 | The above copyright notice and this permission notice shall be 58 | included in all copies or substantial portions of the Software. 59 | 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 61 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 62 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 63 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 64 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 65 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 66 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 67 | 68 | Title 69 | RZUtils 70 | Type 71 | PSGroupSpecifier 72 | 73 | 74 | FooterText 75 | Generated by CocoaPods - http://cocoapods.org 76 | Title 77 | 78 | Type 79 | PSGroupSpecifier 80 | 81 | 82 | StringsTable 83 | Acknowledgements 84 | Title 85 | Acknowledgements 86 | 87 | 88 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RZIntrinsicContentSizeTextView : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RZIntrinsicContentSizeTextView 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // RZIntrinsicContentSizeTextView 10 | #define COCOAPODS_POD_AVAILABLE_RZIntrinsicContentSizeTextView 11 | #define COCOAPODS_VERSION_MAJOR_RZIntrinsicContentSizeTextView 0 12 | #define COCOAPODS_VERSION_MINOR_RZIntrinsicContentSizeTextView 1 13 | #define COCOAPODS_VERSION_PATCH_RZIntrinsicContentSizeTextView 0 14 | 15 | // RZUtils/Categories/UIView 16 | #define COCOAPODS_POD_AVAILABLE_RZUtils_Categories_UIView 17 | #define COCOAPODS_VERSION_MAJOR_RZUtils_Categories_UIView 2 18 | #define COCOAPODS_VERSION_MINOR_RZUtils_Categories_UIView 4 19 | #define COCOAPODS_VERSION_PATCH_RZUtils_Categories_UIView 0 20 | 21 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES="" 10 | 11 | install_resource() 12 | { 13 | case $1 in 14 | *.storyboard) 15 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 16 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 17 | ;; 18 | *.xib) 19 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 20 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 21 | ;; 22 | *.framework) 23 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 25 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 26 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 27 | ;; 28 | *.xcdatamodel) 29 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 30 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 31 | ;; 32 | *.xcdatamodeld) 33 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 34 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 35 | ;; 36 | *.xcmappingmodel) 37 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 38 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 39 | ;; 40 | *.xcassets) 41 | XCASSET_FILES="$XCASSET_FILES '$1'" 42 | ;; 43 | /*) 44 | echo "$1" 45 | echo "$1" >> "$RESOURCES_TO_COPY" 46 | ;; 47 | *) 48 | echo "${PODS_ROOT}/$1" 49 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 50 | ;; 51 | esac 52 | } 53 | 54 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 55 | if [[ "${ACTION}" == "install" ]]; then 56 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 57 | fi 58 | rm -f "$RESOURCES_TO_COPY" 59 | 60 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n $XCASSET_FILES ] 61 | then 62 | case "${TARGETED_DEVICE_FAMILY}" in 63 | 1,2) 64 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 65 | ;; 66 | 1) 67 | TARGET_DEVICE_ARGS="--target-device iphone" 68 | ;; 69 | 2) 70 | TARGET_DEVICE_ARGS="--target-device ipad" 71 | ;; 72 | *) 73 | TARGET_DEVICE_ARGS="--target-device mac" 74 | ;; 75 | esac 76 | echo $XCASSET_FILES | xargs actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 77 | fi 78 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" -isystem "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView" -l"Pods-RZIntrinsicContentSizeTextView-RZUtils" -framework "Foundation" -framework "UIKit" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RZIntrinsicContentSizeTextView/Pods-RZIntrinsicContentSizeTextView.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" -isystem "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-RZIntrinsicContentSizeTextView-RZIntrinsicContentSizeTextView" -l"Pods-RZIntrinsicContentSizeTextView-RZUtils" -framework "Foundation" -framework "UIKit" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests-RZIntrinsicContentSizeTextView/Pods-Tests-RZIntrinsicContentSizeTextView-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-Tests-RZIntrinsicContentSizeTextView.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = -ObjC 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests-RZIntrinsicContentSizeTextView/Pods-Tests-RZIntrinsicContentSizeTextView-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Tests_RZIntrinsicContentSizeTextView : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Tests_RZIntrinsicContentSizeTextView 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests-RZIntrinsicContentSizeTextView/Pods-Tests-RZIntrinsicContentSizeTextView-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-Tests-environment.h" 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests-RZIntrinsicContentSizeTextView/Pods-Tests-RZIntrinsicContentSizeTextView.xcconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/RZIntrinsicContentSizeTextView/094deef4260f44453620fc9747ece191ad7ba056/Example/Pods/Target Support Files/Pods-Tests-RZIntrinsicContentSizeTextView/Pods-Tests-RZIntrinsicContentSizeTextView.xcconfig -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RZIntrinsicContentSizeTextView 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2015 Raizlabs 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | Generated by CocoaPods - http://cocoapods.org 29 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2015 Raizlabs 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | Title 40 | RZIntrinsicContentSizeTextView 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Generated by CocoaPods - http://cocoapods.org 47 | Title 48 | 49 | Type 50 | PSGroupSpecifier 51 | 52 | 53 | StringsTable 54 | Acknowledgements 55 | Title 56 | Acknowledgements 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // RZIntrinsicContentSizeTextView 10 | #define COCOAPODS_POD_AVAILABLE_RZIntrinsicContentSizeTextView 11 | #define COCOAPODS_VERSION_MAJOR_RZIntrinsicContentSizeTextView 0 12 | #define COCOAPODS_VERSION_MINOR_RZIntrinsicContentSizeTextView 1 13 | #define COCOAPODS_VERSION_PATCH_RZIntrinsicContentSizeTextView 0 14 | 15 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES="" 10 | 11 | install_resource() 12 | { 13 | case $1 in 14 | *.storyboard) 15 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 16 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 17 | ;; 18 | *.xib) 19 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 20 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 21 | ;; 22 | *.framework) 23 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 25 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 26 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 27 | ;; 28 | *.xcdatamodel) 29 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 30 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 31 | ;; 32 | *.xcdatamodeld) 33 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 34 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 35 | ;; 36 | *.xcmappingmodel) 37 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 38 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 39 | ;; 40 | *.xcassets) 41 | XCASSET_FILES="$XCASSET_FILES '$1'" 42 | ;; 43 | /*) 44 | echo "$1" 45 | echo "$1" >> "$RESOURCES_TO_COPY" 46 | ;; 47 | *) 48 | echo "${PODS_ROOT}/$1" 49 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 50 | ;; 51 | esac 52 | } 53 | 54 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 55 | if [[ "${ACTION}" == "install" ]]; then 56 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 57 | fi 58 | rm -f "$RESOURCES_TO_COPY" 59 | 60 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n $XCASSET_FILES ] 61 | then 62 | case "${TARGETED_DEVICE_FAMILY}" in 63 | 1,2) 64 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 65 | ;; 66 | 1) 67 | TARGET_DEVICE_ARGS="--target-device iphone" 68 | ;; 69 | 2) 70 | TARGET_DEVICE_ARGS="--target-device ipad" 71 | ;; 72 | *) 73 | TARGET_DEVICE_ARGS="--target-device mac" 74 | ;; 75 | esac 76 | echo $XCASSET_FILES | xargs actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 77 | fi 78 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" -isystem "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-Tests-RZIntrinsicContentSizeTextView" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" "${PODS_ROOT}/Headers/Public/RZUtils" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/RZIntrinsicContentSizeTextView" -isystem "${PODS_ROOT}/Headers/Public/RZUtils" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Pods-Tests-RZIntrinsicContentSizeTextView" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView.xcodeproj/xcshareddata/xcschemes/RZIntrinsicContentSizeTextView-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZAppDelegate.h 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by CocoaPods on 03/16/2015. 6 | // Copyright (c) 2014 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | // Copyright (c) 2015 Raizlabs and other contributors 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | 30 | @import UIKit; 31 | 32 | @interface RZAppDelegate : UIResponder 33 | 34 | @property (strong, nonatomic) UIWindow *window; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZAppDelegate.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by CocoaPods on 03/16/2015. 6 | // Copyright (c) 2014 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | // Copyright (c) 2015 Raizlabs and other contributors 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | 30 | #import "RZAppDelegate.h" 31 | 32 | #import "RZViewController.h" 33 | 34 | @implementation RZAppDelegate 35 | 36 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 37 | { 38 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 39 | self.window.rootViewController = [[RZViewController alloc] initWithNibName:nil bundle:nil]; 40 | [self.window makeKeyAndVisible]; 41 | return YES; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZIntrinsicContentSizeTextView-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZIntrinsicContentSizeTextView-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import UIKit; 15 | @import Foundation; 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZViewController.h 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 03/16/2015. 6 | // Copyright (c) 2014 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | // Copyright (c) 2015 Raizlabs and other contributors 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | 30 | @import UIKit; 31 | 32 | @class RZIntrinsicContentSizeTextView; 33 | 34 | @interface RZViewController : UIViewController 35 | 36 | @property (strong, nonatomic, readonly) RZIntrinsicContentSizeTextView *textView; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZViewController.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 03/16/2015. 6 | // Copyright (c) 2014 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | // Copyright (c) 2015 Raizlabs and other contributors 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | 30 | #import "RZViewController.h" 31 | 32 | #import "RZIntrinsicContentSizeTextView.h" 33 | 34 | @interface RZViewController () 35 | 36 | @property (strong, nonatomic, readwrite) RZIntrinsicContentSizeTextView *textView; 37 | 38 | @property (strong, nonatomic) NSLayoutConstraint *bottomConstraint; 39 | 40 | @end 41 | 42 | @implementation RZViewController 43 | 44 | #pragma mark - Object Lifecycle 45 | 46 | - (void)dealloc 47 | { 48 | [[NSNotificationCenter defaultCenter] removeObserver:self 49 | name:UIKeyboardWillShowNotification 50 | object:nil]; 51 | [[NSNotificationCenter defaultCenter] removeObserver:self 52 | name:UIKeyboardWillShowNotification 53 | object:nil]; 54 | } 55 | 56 | #pragma mark - View Controller Lifecycle 57 | 58 | - (void)viewDidLoad 59 | { 60 | [super viewDidLoad]; 61 | 62 | self.view.backgroundColor = [UIColor lightGrayColor]; 63 | 64 | // add textview to view 65 | self.textView = [[RZIntrinsicContentSizeTextView alloc] initWithFrame:CGRectZero]; 66 | self.textView.translatesAutoresizingMaskIntoConstraints = NO; 67 | [self.view addSubview:self.textView]; 68 | 69 | // set textview attributes 70 | self.textView.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 71 | self.textView.sizeChangeDelegate = self; 72 | 73 | // set placeholder attributes 74 | self.textView.placeholder = @"Hey hey hey"; 75 | self.textView.placeholderTextColor = [UIColor redColor]; 76 | 77 | // Pin the textview to the bottom of the view 78 | NSDictionary *views = NSDictionaryOfVariableBindings(_textView,self.view); 79 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_textView]|" 80 | options:0 81 | metrics:nil 82 | views:views]]; 83 | self.bottomConstraint = [NSLayoutConstraint constraintWithItem:self.view 84 | attribute:NSLayoutAttributeBottom 85 | relatedBy:NSLayoutRelationEqual 86 | toItem:self.textView 87 | attribute:NSLayoutAttributeBottom 88 | multiplier:1.0f 89 | constant:0.0f]; 90 | [self.view addConstraint:self.bottomConstraint]; 91 | 92 | // set min/max constraints 93 | NSLayoutConstraint *minHeightConstraint = [NSLayoutConstraint constraintWithItem:self.textView 94 | attribute:NSLayoutAttributeHeight 95 | relatedBy:NSLayoutRelationGreaterThanOrEqual 96 | toItem:nil 97 | attribute:NSLayoutAttributeNotAnAttribute 98 | multiplier:1.0f 99 | constant:40.0f]; 100 | [self.textView addConstraint:minHeightConstraint]; 101 | 102 | NSLayoutConstraint *maxHeightConstraint = [NSLayoutConstraint constraintWithItem:self.textView 103 | attribute:NSLayoutAttributeHeight 104 | relatedBy:NSLayoutRelationLessThanOrEqual 105 | toItem:nil 106 | attribute:NSLayoutAttributeNotAnAttribute 107 | multiplier:1.0f 108 | constant:100.0f]; 109 | [self.textView addConstraint:maxHeightConstraint]; 110 | 111 | 112 | [[NSNotificationCenter defaultCenter] addObserver:self 113 | selector:@selector(moveKeyboard:) 114 | name:UIKeyboardWillShowNotification 115 | object:nil]; 116 | [[NSNotificationCenter defaultCenter] addObserver:self 117 | selector:@selector(moveKeyboard:) 118 | name:UIKeyboardWillHideNotification 119 | object:nil]; 120 | 121 | } 122 | 123 | #pragma mark - UIKeyboard Notifications 124 | 125 | - (void)moveKeyboard:(NSNotification *)notification 126 | { 127 | NSDictionary *keyboardInfo = notification.userInfo; 128 | CGFloat keyboardEndPoint = CGRectGetMinY([keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]); 129 | CGFloat keyboardTotalHeight = CGRectGetHeight([keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]); 130 | CGFloat duration = [keyboardInfo[UIKeyboardAnimationCurveUserInfoKey] floatValue]; 131 | UIViewAnimationOptions animationOptions = [keyboardInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue] << 16; 132 | 133 | self.bottomConstraint.constant = ( keyboardEndPoint != CGRectGetHeight([UIScreen mainScreen].bounds) ) ? keyboardTotalHeight : 0.0f; 134 | [self.view setNeedsLayout]; 135 | 136 | [UIView animateWithDuration:duration delay:0.0f options:animationOptions animations:^{ 137 | [self.view layoutIfNeeded]; 138 | } completion:nil]; 139 | } 140 | 141 | #pragma mark - RZIntrinsicContentSizeTextViewSizeChangedDelegate 142 | 143 | - (BOOL)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView shouldAnimateToSize:(CGSize)toSize 144 | { 145 | return YES; 146 | } 147 | 148 | - (UIView *)intrinsicTextViewLayoutView:(RZIntrinsicContentSizeTextView *)textView 149 | { 150 | return self.view; 151 | } 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/RZViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/UIView+RZMinMaxAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZMinMaxAutoLayoutHelpers.h 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 3/20/15. 6 | // Copyright (c) 2015 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (RZMinMaxAutoLayoutHelpers) 12 | 13 | // getters 14 | - (NSLayoutConstraint *)rztv_pinnedMinHeightConstraint; 15 | - (NSLayoutConstraint *)rztv_pinnedMaxHeightConstraint; 16 | 17 | // generators 18 | - (NSLayoutConstraint *)rztv_pinMinHeightTo:(CGFloat)height; 19 | - (NSLayoutConstraint *)rztv_pinMaxHeightTo:(CGFloat)height; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/UIView+RZMinMaxAutoLayoutHelpers.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZMinMaxAutoLayoutHelpers.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 3/20/15. 6 | // Copyright (c) 2015 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | #import "UIView+RZMinMaxAutoLayoutHelpers.h" 10 | 11 | @implementation UIView (RZMinMaxAutoLayoutHelpers) 12 | 13 | - (NSLayoutConstraint *)rztv_pinnedMinHeightConstraint 14 | { 15 | __block NSLayoutConstraint *constraint = nil; 16 | [self.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 17 | if (c.firstItem == self && 18 | c.firstAttribute == NSLayoutAttributeHeight && 19 | c.secondAttribute == NSLayoutAttributeNotAnAttribute && 20 | c.relation == NSLayoutRelationGreaterThanOrEqual) 21 | { 22 | constraint = c; 23 | *stop = YES; 24 | } 25 | }]; 26 | return constraint; 27 | } 28 | 29 | - (NSLayoutConstraint *)rztv_pinnedMaxHeightConstraint 30 | { 31 | __block NSLayoutConstraint *constraint = nil; 32 | [self.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 33 | if (c.firstItem == self && 34 | c.firstAttribute == NSLayoutAttributeHeight && 35 | c.secondAttribute == NSLayoutAttributeNotAnAttribute && 36 | c.relation == NSLayoutRelationLessThanOrEqual) 37 | { 38 | constraint = c; 39 | *stop = YES; 40 | } 41 | }]; 42 | return constraint; 43 | } 44 | 45 | - (NSLayoutConstraint *)rztv_pinMinHeightTo:(CGFloat)height 46 | { 47 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 48 | attribute:NSLayoutAttributeHeight 49 | relatedBy:NSLayoutRelationGreaterThanOrEqual 50 | toItem:nil 51 | attribute:NSLayoutAttributeNotAnAttribute 52 | multiplier:1.0f 53 | constant:height]; 54 | [self addConstraint:h]; 55 | 56 | return h; 57 | } 58 | 59 | - (NSLayoutConstraint *)rztv_pinMaxHeightTo:(CGFloat)height 60 | { 61 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 62 | attribute:NSLayoutAttributeHeight 63 | relatedBy:NSLayoutRelationLessThanOrEqual 64 | toItem:nil 65 | attribute:NSLayoutAttributeNotAnAttribute 66 | multiplier:1.0f 67 | constant:height]; 68 | [self addConstraint:h]; 69 | 70 | return h; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/RZIntrinsicContentSizeTextView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 03/16/2015. 6 | // Copyright (c) 2014 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "RZAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([RZAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Tests/RZIntrinsicContentSizeTextViewUITest.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZIntrinsicContentSizeTextViewUITest.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 3/20/15. 6 | // Copyright (c) 2015 Derek Ostrander. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RZIntrinsicContentSizeTextViewUITest : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RZIntrinsicContentSizeTextViewUITest 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/Tests/RZTestConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZTestConstants.h 3 | // RZIntrinsicContentTextView 4 | // 5 | // Created by Derek Ostrander on 3/6/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | #define APP ((RZAppDelegate *)[UIApplication sharedApplication].delegate) 29 | 30 | OBJC_EXTERN NSString* const kRZShortText; 31 | OBJC_EXTERN NSString* const kRZLongText; 32 | OBJC_EXTERN NSString* const kRZNewLineText; 33 | OBJC_EXTERN NSString* const kRZNewLineLongText; 34 | 35 | OBJC_EXTERN const CGFloat kRZNoHeight; 36 | OBJC_EXTERN const CGFloat kRZMinHeight; 37 | OBJC_EXTERN const CGFloat kRZMidHeight; 38 | OBJC_EXTERN const CGFloat kRZMaxHeight; 39 | 40 | -------------------------------------------------------------------------------- /Example/Tests/RZTestConstants.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZTestConstants.m 3 | // RZIntrinsicContentSizeTextView 4 | // 5 | // Created by Derek Ostrander on 3/6/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | #import "RZTestConstants.h" 29 | 30 | NSString* const kRZShortText = @"FRY"; 31 | NSString* const kRZLongText = @"Lorem ipsum dolor sit amet, accumsan sapien eget ultrices ut ipsum per, velit orci quisque nec malesuada, ut nibh ut accumsan. Accumsan cursus sunt ligula tempus. Ullamcorper quam. Velit a pellentesque faucibus et faucibus, sit a nunc, arcu ac vel justo sed leo. Aliquam non, rhoncus augue sed elementum, mauris aliquet nulla fermentum a sed. Vel donec sapien et, eleifend ut gravida sapien. Erat tristique justo vestibulum eget risus, dictum nullam tortor massa, et justo duis tincidunt scelerisque, suspendisse pulvinar rutrum amet eget. Aliquam nec, fringilla pellentesque sed nulla malesuada. Et vehicula integer blandit risus maecenas."; 32 | NSString* const kRZNewLineText = @"\n\n\n\n\n"; 33 | NSString* const kRZNewLineLongText = @"Hey this is some kind of longer text.\n\n\n\n\nLet's make this long enough to at least span around 3 lines on a normal iPhone screen."; 34 | 35 | const CGFloat kRZNoHeight = 0.0f; 36 | const CGFloat kRZMinHeight = 30.0f; 37 | const CGFloat kRZMidHeight = 120.0f; 38 | const CGFloat kRZMaxHeight = 200.0f; 39 | -------------------------------------------------------------------------------- /Example/Tests/Tests-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 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every test case source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | 9 | @import XCTest; 10 | @import UIKit; 11 | 12 | #import "RZTestConstants.h" 13 | #import "UIView+RZAutoLayoutHelpers.h" 14 | #import "RZIntrinsicContentSizeTextView.h" 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Example/Tests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Raizlabs 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 | 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /Pod/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/RZIntrinsicContentSizeTextView/094deef4260f44453620fc9747ece191ad7ba056/Pod/Assets/.gitkeep -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutHelpers.h 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | @import UIKit; 29 | 30 | @interface UIView (RZAutoLayoutHelpers) 31 | 32 | // getters 33 | - (NSLayoutConstraint*)rztv_pinnedHeightConstraint; 34 | - (NSLayoutConstraint*)rztv_pinnedTopConstraint; 35 | - (NSLayoutConstraint*)rztv_pinnedLeftConstraint; 36 | - (NSLayoutConstraint*)rztv_pinnedRightConstraint; 37 | - (NSLayoutConstraint*)rztv_pinnedBottomConstraint; 38 | 39 | // setters 40 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height; 41 | - (NSLayoutConstraint *)rztv_pinTopSpaceToSuperviewWithPadding:(CGFloat)padding; 42 | - (NSLayoutConstraint *)rztv_pinLeftSpaceToSuperviewWithPadding:(CGFloat)padding; 43 | - (NSLayoutConstraint *)rztv_pinBottomSpaceToSuperviewWithPadding:(CGFloat)padding; 44 | - (NSLayoutConstraint *)rztv_pinRightSpaceToSuperviewWithPadding:(CGFloat)padding; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutHelpers.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutHelpers.m 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | #import "UIView+RZAutoLayoutHelpers.h" 29 | 30 | @implementation UIView (RZAutoLayoutHelpers) 31 | 32 | # pragma mark - Helpers 33 | 34 | - (BOOL)rztv_constraintIsWithSuperview:(NSLayoutConstraint *)constraint 35 | { 36 | return ((constraint.firstItem == self && constraint.secondItem == self.superview) || 37 | (constraint.firstItem == self.superview && constraint.secondItem == self)); 38 | } 39 | 40 | + (UIView *)rztv_commonAncestorForViews:(NSArray *)views 41 | { 42 | NSParameterAssert([views count] > 0); 43 | 44 | if ( [views count] == 1 ) { 45 | return [views firstObject]; 46 | } 47 | 48 | // First, build a list of view hierarchies, where each element is a list containing the hierarhcy all the way up from each view to the top 49 | NSMutableArray *viewHierarchies = [[NSMutableArray alloc] initWithCapacity:[views count]]; 50 | for ( UIView *view in views ) { 51 | NSMutableArray *viewHierarchy = [NSMutableArray array]; 52 | 53 | UIView *viewCursor = view; 54 | while ( viewCursor != nil ) { 55 | [viewHierarchy addObject:viewCursor]; 56 | viewCursor = [viewCursor superview]; 57 | } 58 | 59 | [viewHierarchies addObject:viewHierarchy]; 60 | } 61 | 62 | // Next, iterate through the view hierarchies. Find the first element that they all have in common. Note that this is n^2, but is quite unlikely this will ever hamper performance because view hierarchies should generally be quite shallow. 63 | UIView *candidateCommonAncestor = nil; 64 | NSArray *firstViewHierarchy = [viewHierarchies firstObject]; 65 | NSArray *otherViewHierarchies = [viewHierarchies subarrayWithRange:NSMakeRange(1, [viewHierarchies count] - 1)]; 66 | 67 | for ( UIView *view in firstViewHierarchy ) { 68 | BOOL commonAncestorMatches = YES; 69 | 70 | for ( NSArray *otherViewHierarchy in otherViewHierarchies ) { 71 | if ( [otherViewHierarchy containsObject:view] == NO ) { 72 | commonAncestorMatches = NO; 73 | break; 74 | } 75 | } 76 | 77 | if ( commonAncestorMatches ) { 78 | candidateCommonAncestor = view; 79 | break; 80 | } 81 | } 82 | 83 | return candidateCommonAncestor; 84 | } 85 | 86 | # pragma mark - Constraint Accessors 87 | 88 | - (NSLayoutConstraint *)rztv_pinnedHeightConstraint 89 | { 90 | __block NSLayoutConstraint *constraint = nil; 91 | [self.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 92 | if (c.firstItem == self && 93 | c.firstAttribute == NSLayoutAttributeHeight && 94 | c.secondAttribute == NSLayoutAttributeNotAnAttribute && 95 | c.relation == NSLayoutRelationEqual) 96 | { 97 | constraint = c; 98 | *stop = YES; 99 | } 100 | }]; 101 | return constraint; 102 | } 103 | 104 | - (NSLayoutConstraint*)rztv_pinnedTopConstraint 105 | { 106 | if (self.superview == nil) return nil; 107 | 108 | __block NSLayoutConstraint *constraint = nil; 109 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 110 | if ([self rztv_constraintIsWithSuperview:c] && 111 | c.firstAttribute == NSLayoutAttributeTop && 112 | c.secondAttribute == NSLayoutAttributeTop && 113 | c.relation == NSLayoutRelationEqual) 114 | { 115 | constraint = c; 116 | *stop = YES; 117 | } 118 | }]; 119 | return constraint; 120 | } 121 | 122 | - (NSLayoutConstraint*)rztv_pinnedLeftConstraint 123 | { 124 | if (self.superview == nil) return nil; 125 | 126 | __block NSLayoutConstraint *constraint = nil; 127 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 128 | if ([self rztv_constraintIsWithSuperview:c] && 129 | (c.firstAttribute == NSLayoutAttributeLeft || c.firstAttribute == NSLayoutAttributeLeading) && 130 | (c.secondAttribute == NSLayoutAttributeLeft || c.secondAttribute == NSLayoutAttributeLeading) && 131 | c.relation == NSLayoutRelationEqual) 132 | { 133 | constraint = c; 134 | *stop = YES; 135 | } 136 | }]; 137 | return constraint; 138 | } 139 | 140 | - (NSLayoutConstraint*)rztv_pinnedRightConstraint 141 | { 142 | if (self.superview == nil) return nil; 143 | 144 | __block NSLayoutConstraint *constraint = nil; 145 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 146 | if ([self rztv_constraintIsWithSuperview:c] && 147 | (c.firstAttribute == NSLayoutAttributeRight || c.firstAttribute == NSLayoutAttributeTrailing) && 148 | (c.secondAttribute == NSLayoutAttributeRight || c.secondAttribute == NSLayoutAttributeTrailing) && 149 | c.relation == NSLayoutRelationEqual) 150 | { 151 | constraint = c; 152 | *stop = YES; 153 | } 154 | }]; 155 | return constraint; 156 | } 157 | 158 | - (NSLayoutConstraint*)rztv_pinnedBottomConstraint 159 | { 160 | if (self.superview == nil) return nil; 161 | 162 | __block NSLayoutConstraint *constraint = nil; 163 | [[[self superview] constraints] enumerateObjectsUsingBlock:^(NSLayoutConstraint *c, NSUInteger idx, BOOL *stop) { 164 | if ([self rztv_constraintIsWithSuperview:c] && 165 | c.firstAttribute == NSLayoutAttributeBottom && 166 | c.secondAttribute == NSLayoutAttributeBottom && 167 | c.relation == NSLayoutRelationEqual) 168 | { 169 | constraint = c; 170 | *stop = YES; 171 | } 172 | }]; 173 | return constraint; 174 | } 175 | 176 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height 177 | { 178 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 179 | attribute:NSLayoutAttributeHeight 180 | relatedBy:NSLayoutRelationEqual 181 | toItem:nil 182 | attribute:NSLayoutAttributeNotAnAttribute 183 | multiplier:1.0f 184 | constant:height]; 185 | [self addConstraint:h]; 186 | 187 | return h; 188 | } 189 | 190 | - (NSLayoutConstraint *)rztv_pinTopSpaceToSuperviewWithPadding:(CGFloat)padding 191 | { 192 | NSAssert(self.superview != nil, @"Must have superview"); 193 | 194 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 195 | attribute:NSLayoutAttributeTop 196 | relatedBy:NSLayoutRelationEqual 197 | toItem:self.superview 198 | attribute:NSLayoutAttributeTop 199 | multiplier:1.0f 200 | constant:padding]; 201 | [self.superview addConstraint:c]; 202 | 203 | return c; 204 | } 205 | 206 | - (NSLayoutConstraint *)rztv_pinLeftSpaceToSuperviewWithPadding:(CGFloat)padding 207 | { 208 | NSAssert(self.superview != nil, @"Must have superview"); 209 | 210 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 211 | attribute:NSLayoutAttributeLeft 212 | relatedBy:NSLayoutRelationEqual 213 | toItem:self.superview 214 | attribute:NSLayoutAttributeLeft 215 | multiplier:1.0f 216 | constant:padding]; 217 | [self.superview addConstraint:c]; 218 | 219 | return c; 220 | } 221 | 222 | - (NSLayoutConstraint *)rztv_pinBottomSpaceToSuperviewWithPadding:(CGFloat)padding 223 | { 224 | NSAssert(self.superview != nil, @"Must have superview"); 225 | 226 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 227 | attribute:NSLayoutAttributeBottom 228 | relatedBy:NSLayoutRelationEqual 229 | toItem:self.superview 230 | attribute:NSLayoutAttributeBottom 231 | multiplier:1.0f 232 | constant:-padding]; 233 | [self.superview addConstraint:c]; 234 | 235 | return c; 236 | } 237 | 238 | - (NSLayoutConstraint *)rztv_pinRightSpaceToSuperviewWithPadding:(CGFloat)padding 239 | { 240 | NSAssert(self.superview != nil, @"Must have superview"); 241 | 242 | NSLayoutConstraint *c = [NSLayoutConstraint constraintWithItem:self 243 | attribute:NSLayoutAttributeRight 244 | relatedBy:NSLayoutRelationEqual 245 | toItem:self.superview 246 | attribute:NSLayoutAttributeRight 247 | multiplier:1.0f 248 | constant:-padding]; 249 | [self.superview addConstraint:c]; 250 | 251 | return c; 252 | } 253 | 254 | @end 255 | -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutPriorityHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutPriorityHelpers.h 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | @import UIKit; 29 | 30 | @interface UIView (RZAutoLayoutPriorityHelpers) 31 | 32 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height priority:(CGFloat)priority; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutPriorityHelpers.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutPriorityHelpers.m 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | #import "UIView+RZAutoLayoutPriorityHelpers.h" 29 | 30 | @implementation UIView (RZAutoLayoutPriorityHelpers) 31 | 32 | - (NSLayoutConstraint *)rztv_pinHeightTo:(CGFloat)height priority:(CGFloat)priority 33 | { 34 | NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:self 35 | attribute:NSLayoutAttributeHeight 36 | relatedBy:NSLayoutRelationEqual 37 | toItem:nil 38 | attribute:NSLayoutAttributeNotAnAttribute 39 | multiplier:1.0f 40 | constant:height]; 41 | 42 | if ( !isnan(priority) ) { 43 | h.priority = priority; 44 | } 45 | 46 | [self addConstraint:h]; 47 | 48 | return h; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutReplacementHelpers.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutReplacementHelpers.h 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | // 7 | // 8 | 9 | // Copyright (c) 2015 Raizlabs and other contributors 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // 27 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | // SOFTWARE. 29 | 30 | @import UIKit; 31 | 32 | @interface UIView (RZAutoLayoutReplacementHelpers) 33 | 34 | - (NSLayoutConstraint *)rztv_replacePinnedHeightConstraintWithNewPinnedHeight:(CGFloat)height priority:(CGFloat)priority; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Pod/Categories/UIView+RZAutoLayoutReplacementHelpers.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+RZAutoLayoutReplacementHelpers.m 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | #import "UIView+RZAutoLayoutReplacementHelpers.h" 29 | #import "UIView+RZAutoLayoutHelpers.h" 30 | #import "UIView+RZAutoLayoutPriorityHelpers.h" 31 | 32 | @implementation UIView (RZAutoLayoutReplacementHelpers) 33 | 34 | - (NSLayoutConstraint *)rztv_replacePinnedHeightConstraintWithNewPinnedHeight:(CGFloat)height 35 | { 36 | return [self rztv_replacePinnedHeightConstraintWithNewPinnedHeight:height priority:nanf(NULL)]; 37 | } 38 | 39 | - (NSLayoutConstraint *)rztv_replacePinnedHeightConstraintWithNewPinnedHeight:(CGFloat)height priority:(CGFloat)priority 40 | { 41 | NSLayoutConstraint *rztv_pinnedHeightConstraint = self.rztv_pinnedHeightConstraint; 42 | 43 | if ( rztv_pinnedHeightConstraint ) { 44 | [self removeConstraint:rztv_pinnedHeightConstraint]; 45 | } 46 | 47 | return [self rztv_pinHeightTo:height priority:priority]; 48 | 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Pod/Classes/RZIntrinsicContentSizeTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZIntrinsicContentSizeTextView.h 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | @import UIKit; 29 | 30 | @protocol RZIntrinsicContentSizeTextViewSizeChangedDelegate; 31 | 32 | /** 33 | * This is a UITextView subclass that will grow and shrink with it's intrinsicContentSize. 34 | */ 35 | IB_DESIGNABLE 36 | @interface RZIntrinsicContentSizeTextView : UITextView 37 | 38 | /** 39 | * Priority for the height constraint of the UITextView. 40 | * @note this may have to be changed if you have other constraints being placed on textview 41 | * that the height constraint will need to give or vice versa. 42 | * @default is 999.0f 43 | */ 44 | @property (assign, nonatomic, readwrite) IBInspectable CGFloat heightPriority; 45 | 46 | /** 47 | * Set this to have placeholder text 48 | */ 49 | @property (copy, nonatomic, readwrite) IBInspectable NSString *placeholder; 50 | 51 | /** 52 | * Custom textcolor of the placeholder 53 | */ 54 | @property (strong, nonatomic, readwrite) IBInspectable UIColor *placeholderTextColor; 55 | 56 | /** 57 | * Set this to have attributed placeholder text 58 | */ 59 | @property (copy, nonatomic, readwrite) NSAttributedString *attributedPlaceholder; 60 | 61 | /** 62 | * Delegate to have more fine tuned control for if/when/how it should change it's size. 63 | * @note in many instances you won't have to use this. 64 | */ 65 | @property (weak, nonatomic, readwrite) id sizeChangeDelegate; 66 | 67 | @end 68 | 69 | @protocol RZIntrinsicContentSizeTextViewSizeChangedDelegate 70 | 71 | @optional 72 | 73 | /** 74 | * @param textView The textview that is about to change size 75 | * @param toSize The size it is projected to change to 76 | * 77 | * @return Whether or not the textview should animate it's size change. (Default is YES) 78 | * @note this defaults to YES 79 | */ 80 | - (BOOL)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView shouldAnimateToSize:(CGSize)toSize; 81 | 82 | /** 83 | * The view that is called during layoutIfNeeded to animate correctly. 84 | * @note this is only needed if you are seeing clipping during your animations 85 | * 86 | * @param textView The textview that is about to change size 87 | * 88 | * @return The view that gets called for layoutIfNeeded 89 | * @note this defaults to the intrinsicTextView's superview 90 | */ 91 | - (UIView *)intrinsicTextViewLayoutView:(RZIntrinsicContentSizeTextView *)textView; 92 | 93 | // TODO: Implement these 94 | ///** 95 | // * @param textView The textview that is about to change size 96 | // * @param toSize The size it is projected to change to 97 | // * 98 | // * @return Whether or not the textview should change to it's new size 99 | // * @note this defaults to YES 100 | // */ 101 | //- (BOOL)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView shouldChangeToSize:(CGSize)toSize; 102 | // 103 | ///** 104 | // * Called before the size change 105 | // * 106 | // * @param textView The textview that is about to change size 107 | // * @param toSize The size it is projected to change to 108 | // */ 109 | //- (void)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView willChangeToSize:(CGSize)toSize; 110 | // 111 | ///** 112 | // * Called after the size change 113 | // * 114 | // * @param textView The textview that is about to change size 115 | // * @param toSize The size it is projected to change to 116 | // */ 117 | //- (void)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView didChangeToSize:(CGSize)toSize; 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Pod/Classes/RZIntrinsicContentSizeTextView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZIntrinsicContentSizeTextView.m 3 | // Pods 4 | // 5 | // Created by Derek Ostrander on 3/16/15. 6 | 7 | // Copyright (c) 2015 Raizlabs and other contributors 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | // SOFTWARE. 27 | 28 | 29 | #import "RZIntrinsicContentSizeTextView.h" 30 | #import "UIView+RZAutoLayoutHelpers.h" 31 | #import "UIView+RZAutoLayoutPriorityHelpers.h" 32 | #import "UIView+RZAutoLayoutReplacementHelpers.h" 33 | 34 | static const CGFloat kRZTextViewAnimationDuration = 0.2f; 35 | static const CGFloat kRZTextViewDefaultHeightPriority = 999.0f; 36 | 37 | @interface RZIntrinsicContentSizeTextView () 38 | 39 | // Placholder 40 | @property (strong, nonatomic, readwrite) UILabel *placeholderLabel; 41 | 42 | // Dynamic Min/Max constraints 43 | @property (weak, nonatomic, readonly) NSLayoutConstraint *rztv_minHeightConstraint; 44 | @property (weak, nonatomic, readonly) NSLayoutConstraint *rztv_maxHeightConstraint; 45 | 46 | // Predicate helpers 47 | + (NSPredicate *)rztv_minConstraintPredicate; 48 | + (NSPredicate *)rztv_maxConstraintPredicate; 49 | 50 | // Size Helpers 51 | - (CGFloat)intrinsicContentHeight; 52 | 53 | // Delegate helpers 54 | - (UIView *)layoutView; 55 | - (BOOL)shouldAnimateSizeChange; 56 | 57 | // Scroll Helpers 58 | - (BOOL)shouldScrollToBottom; 59 | - (CGPoint)bottomOffset; 60 | 61 | @end 62 | 63 | @implementation RZIntrinsicContentSizeTextView 64 | 65 | @synthesize rztv_minHeightConstraint = _rztv_minHeightConstraint; 66 | @synthesize rztv_maxHeightConstraint = _rztv_maxHeightConstraint; 67 | 68 | #pragma mark - Class 69 | 70 | + (NSPredicate *)rztv_minConstraintPredicate 71 | { 72 | return [NSPredicate predicateWithFormat:@"%K == %@ AND %K == %@", 73 | NSStringFromSelector(@selector(firstAttribute)), @(NSLayoutAttributeHeight), 74 | NSStringFromSelector(@selector(relation)), @(NSLayoutRelationGreaterThanOrEqual)]; 75 | } 76 | 77 | + (NSPredicate *)rztv_maxConstraintPredicate 78 | { 79 | return [NSPredicate predicateWithFormat:@"%K == %@ AND %K == %@", 80 | NSStringFromSelector(@selector(firstAttribute)), @(NSLayoutAttributeHeight), 81 | NSStringFromSelector(@selector(relation)), @(NSLayoutRelationLessThanOrEqual)]; 82 | } 83 | 84 | #pragma mark - View Life Cycle 85 | 86 | - (instancetype)initWithFrame:(CGRect)frame textContainer:(NSTextContainer *)textContainer 87 | { 88 | self = [super initWithFrame:frame textContainer:textContainer]; 89 | if ( self != nil ) { 90 | [self configureIntrinsicTextView]; 91 | } 92 | return self; 93 | } 94 | 95 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 96 | { 97 | self = [super initWithCoder:aDecoder]; 98 | if ( self != nil ) { 99 | [self configureIntrinsicTextView]; 100 | } 101 | return self; 102 | } 103 | 104 | - (void)dealloc 105 | { 106 | [[NSNotificationCenter defaultCenter] removeObserver:self 107 | name:UITextViewTextDidChangeNotification 108 | object:nil]; 109 | } 110 | 111 | - (void)prepareForInterfaceBuilder 112 | { 113 | [super prepareForInterfaceBuilder]; 114 | [self configurePlaceholder]; 115 | [self adjustHeightIfNeededAnimated:NO]; 116 | } 117 | 118 | #pragma mark - Layout 119 | 120 | - (void)layoutSubviews 121 | { 122 | [super layoutSubviews]; 123 | 124 | [self adjustHeightIfNeededAnimated:self.shouldAnimateSizeChange]; 125 | } 126 | 127 | - (CGSize)intrinsicContentSize 128 | { 129 | return CGSizeMake(CGRectGetWidth(self.bounds), self.intrinsicContentHeight); 130 | } 131 | 132 | #pragma mark - Setters 133 | 134 | // custom setters 135 | - (void)setHeightPriority:(CGFloat)heightPriority 136 | { 137 | if ( _heightPriority != heightPriority ) { 138 | _heightPriority = heightPriority; 139 | 140 | [self rztv_replacePinnedHeightConstraintWithNewPinnedHeight:self.rztv_pinnedHeightConstraint.constant priority:self.heightPriority]; 141 | } 142 | } 143 | 144 | - (void)setPlaceholder:(NSString *)placeholder 145 | { 146 | if ( ![_placeholder isEqualToString:placeholder] ) { 147 | _placeholder = placeholder.copy; 148 | self.placeholderLabel.text = _placeholder; 149 | } 150 | } 151 | 152 | - (void)setAttributedPlaceholder:(NSAttributedString *)attributedPlaceholder 153 | { 154 | if ( ![_attributedPlaceholder isEqualToAttributedString:attributedPlaceholder] ) { 155 | _attributedPlaceholder = attributedPlaceholder.copy; 156 | self.placeholderLabel.attributedText = _attributedPlaceholder; 157 | } 158 | } 159 | 160 | - (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor 161 | { 162 | if ( _placeholderTextColor != placeholderTextColor ) { 163 | _placeholderTextColor = placeholderTextColor; 164 | self.placeholderLabel.textColor = _placeholderTextColor; 165 | } 166 | } 167 | 168 | #pragma mark - Super Setter Overrides 169 | 170 | - (void)setTextContainerInset:(UIEdgeInsets)textContainerInset 171 | { 172 | [super setTextContainerInset:textContainerInset]; 173 | [self adjustPlaceholderPosition]; 174 | [self scrollToBottom]; 175 | } 176 | 177 | - (void)setText:(NSString *)text 178 | { 179 | [super setText:text]; 180 | [self adjustPlaceholderForTextChange]; 181 | [self adjustHeightIfNeededAnimated:self.shouldAnimateSizeChange]; 182 | } 183 | 184 | - (void)setFont:(UIFont *)font 185 | { 186 | [super setFont:font]; 187 | self.placeholderLabel.font = font; 188 | } 189 | 190 | #pragma mark - Getters 191 | 192 | - (NSLayoutConstraint *)rztv_pinnedHeightConstraint 193 | { 194 | NSLayoutConstraint *rztv_pinnedHeightConstraint = super.rztv_pinnedHeightConstraint; 195 | 196 | // create a height constraint if there isn't one created already 197 | if ( !rztv_pinnedHeightConstraint ) { 198 | rztv_pinnedHeightConstraint = [self rztv_pinHeightTo:0.0f priority:self.heightPriority]; 199 | } 200 | 201 | return rztv_pinnedHeightConstraint; 202 | } 203 | 204 | // we need these to be dynamic so we have to iterate through these each time we 205 | // have to look it up. So lookup the min/max sparingly 206 | - (NSLayoutConstraint *)rztv_maxHeightConstraint 207 | { 208 | _rztv_maxHeightConstraint = nil; 209 | for (NSLayoutConstraint *constraint in [self.constraints filteredArrayUsingPredicate:[[self class] rztv_maxConstraintPredicate]]) { 210 | if( _rztv_maxHeightConstraint == nil || constraint.constant < _rztv_maxHeightConstraint.constant ) { 211 | _rztv_maxHeightConstraint = constraint; 212 | } 213 | } 214 | 215 | return _rztv_maxHeightConstraint; 216 | } 217 | 218 | - (NSLayoutConstraint *)rztv_minHeightConstraint 219 | { 220 | _rztv_minHeightConstraint = nil; 221 | for (NSLayoutConstraint *constraint in [self.constraints filteredArrayUsingPredicate:[[self class] rztv_minConstraintPredicate]]) { 222 | if ( _rztv_minHeightConstraint == nil || constraint.constant > _rztv_minHeightConstraint.constant ) { 223 | _rztv_minHeightConstraint = constraint; 224 | } 225 | } 226 | 227 | return _rztv_minHeightConstraint; 228 | } 229 | 230 | #pragma mark - Config 231 | 232 | - (void)configureIntrinsicTextView 233 | { 234 | [self configureDefaults]; 235 | [self configurePlaceholder]; 236 | 237 | [[NSNotificationCenter defaultCenter] addObserver:self 238 | selector:@selector(textViewTextDidChange:) 239 | name:UITextViewTextDidChangeNotification 240 | object:nil]; 241 | } 242 | 243 | - (void)configureDefaults 244 | { 245 | _heightPriority = kRZTextViewDefaultHeightPriority; 246 | _placeholder = nil; 247 | _attributedPlaceholder = nil; 248 | _placeholderTextColor = [UIColor lightGrayColor]; 249 | self.layoutManager.allowsNonContiguousLayout = NO; 250 | } 251 | 252 | - (void)configurePlaceholder 253 | { 254 | _placeholderLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 255 | self.placeholderLabel.translatesAutoresizingMaskIntoConstraints = NO; 256 | self.placeholderLabel.textColor = self.placeholderTextColor; 257 | self.placeholderLabel.text = self.placeholder; 258 | self.placeholderLabel.attributedText = self.attributedPlaceholder; 259 | self.placeholderLabel.font = self.font; 260 | [self addSubview:self.placeholderLabel]; 261 | 262 | // set the constraints, we will update them later 263 | [self.placeholderLabel rztv_pinLeftSpaceToSuperviewWithPadding:0.0f]; 264 | [self.placeholderLabel rztv_pinTopSpaceToSuperviewWithPadding:0.0f]; 265 | 266 | // this will set the placeholder position to the beginning of the document. 267 | [self adjustPlaceholderPosition]; 268 | } 269 | 270 | #pragma mark - Intrinsic Size Helpers 271 | 272 | // Gets the height of the content that is currently in the TextView 273 | - (CGFloat)intrinsicContentHeight 274 | { 275 | CGSize sizeThatFits = [self sizeThatFits:CGSizeMake(CGRectGetWidth(self.frame), 276 | CGFLOAT_MAX)]; 277 | CGFloat newHeight = sizeThatFits.height; 278 | 279 | // store the constraints to avoid extra lookups 280 | NSLayoutConstraint *rztv_maxHeightConstraint = self.rztv_maxHeightConstraint; 281 | NSLayoutConstraint *rztv_minHeightConstraint = self.rztv_minHeightConstraint; 282 | 283 | // Consider the min/max height constraints when calculating the height 284 | if ( rztv_maxHeightConstraint ) { 285 | newHeight = fmin(newHeight, rztv_maxHeightConstraint.constant); 286 | } 287 | 288 | if ( rztv_minHeightConstraint ) { 289 | newHeight = fmax(newHeight, rztv_minHeightConstraint.constant); 290 | } 291 | 292 | // at the very least we want it the size of the font plus insets 293 | CGFloat minimum = fmin(self.textContainerInset.top + self.textContainerInset.bottom + self.font.lineHeight, rztv_maxHeightConstraint.constant); 294 | 295 | return fmax(newHeight, minimum); 296 | } 297 | 298 | #pragma mark - Delegate Helpers 299 | 300 | - (BOOL)shouldAnimateSizeChange 301 | { 302 | return ( ![self.sizeChangeDelegate respondsToSelector:@selector(intrinsicTextView:shouldAnimateToSize:)] || 303 | [self.sizeChangeDelegate intrinsicTextView:self shouldAnimateToSize:self.intrinsicContentSize] ); 304 | } 305 | 306 | - (UIView *)layoutView 307 | { 308 | UIView *layoutView = self.superview ?: self; 309 | if ( [self.sizeChangeDelegate respondsToSelector:@selector(intrinsicTextViewLayoutView:)] ) { 310 | layoutView = [self.sizeChangeDelegate intrinsicTextViewLayoutView:self]; 311 | } 312 | 313 | return layoutView; 314 | } 315 | 316 | #pragma mark - UITextViewNotifications 317 | 318 | - (void)textViewTextDidChange:(NSNotification *)notification 319 | { 320 | // in case there are other textviews showing 321 | if ( notification.object == self ) { 322 | [self adjustHeightIfNeededAnimated:self.shouldAnimateSizeChange]; 323 | [self adjustPlaceholderForTextChange]; 324 | } 325 | } 326 | 327 | #pragma mark - Adjusters 328 | 329 | // Checks the height of the textview and adjusts if needed. 330 | - (void)adjustHeightIfNeededAnimated:(BOOL)animated 331 | { 332 | CGFloat intrinsicHeight = self.intrinsicContentHeight; 333 | BOOL intrinsicHeightChanged = intrinsicHeight != self.rztv_pinnedHeightConstraint.constant; 334 | BOOL isShrinking = intrinsicHeight < self.rztv_pinnedHeightConstraint.constant; 335 | BOOL isIgnoringGrowingConstraint = self.rztv_pinnedHeightConstraint.constant > CGRectGetHeight(self.bounds); 336 | 337 | if ( intrinsicHeightChanged && 338 | ( !isIgnoringGrowingConstraint || isShrinking ) ) { 339 | 340 | self.rztv_pinnedHeightConstraint.constant = intrinsicHeight; 341 | 342 | [self setNeedsLayout]; 343 | 344 | void(^adjustHeightBlock)() = ^{ 345 | [self.layoutView layoutIfNeeded]; 346 | 347 | // This probably should scroll to the selected caret range to be more accurate 348 | // however this works because we only force the scroll when we are changing 349 | // the size of the textview. Once we are at the max size we allow 350 | // the native implementation take care of scrolling. 351 | // TODO: Change to scroll to caret range 352 | if ( self.shouldScrollToBottom ) { 353 | [self scrollToBottom]; 354 | } 355 | }; 356 | 357 | if ( animated ) { 358 | [UIView animateWithDuration:kRZTextViewAnimationDuration 359 | animations:adjustHeightBlock]; 360 | } 361 | else { 362 | adjustHeightBlock(); 363 | } 364 | } 365 | } 366 | 367 | // Adjusts whether the placeholder is hidden or not 368 | - (void)adjustPlaceholderForTextChange 369 | { 370 | self.placeholderLabel.hidden = self.text.length > 0; 371 | } 372 | 373 | - (void)adjustPlaceholderPosition 374 | { 375 | // Set the start point to the beginning of the document. 376 | // This is the best way to get the cursor starting point 377 | // which is where to place the placeholder view 378 | CGRect startRect = [self firstRectForRange:[self textRangeFromPosition:self.beginningOfDocument toPosition:self.beginningOfDocument]]; 379 | 380 | if ( !CGRectIsNull(startRect) ) { 381 | self.placeholderLabel.rztv_pinnedLeftConstraint.constant = CGRectGetMinX(startRect); 382 | self.placeholderLabel.rztv_pinnedTopConstraint.constant = CGRectGetMinY(startRect); 383 | } 384 | } 385 | 386 | #pragma mark - Scroll Helpers 387 | 388 | // Only force the scroll when it is still growing and we don't have a large bottom offset. 389 | // Once we have to scroll over the size of the font it will start clipping 390 | // so allow for the UITextView underlying scrollview scroll itself 391 | - (BOOL)shouldScrollToBottom 392 | { 393 | return self.bottomOffset.y < self.font.lineHeight; 394 | } 395 | 396 | - (CGPoint)bottomOffset 397 | { 398 | return CGPointMake(0.0f, self.contentSize.height - CGRectGetHeight(self.bounds) + fabs(self.textContainerInset.top - self.textContainerInset.bottom)); 399 | } 400 | 401 | - (void)scrollToBottom 402 | { 403 | [self setContentOffset:self.bottomOffset animated:NO]; 404 | } 405 | 406 | @end 407 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RZIntrinsicContentSizeTextView 2 | 3 | 8 | RZIntrinsicContentSizeTextView is a convenient UITextView subclass that has all the features you wish were in UITextView: a placeholder and the ability to dynamically grow based on its content size. 9 | 10 | This is ideal for the many messaging applications where the user is typing into a textview that will start off small, but will then need to grow in height and/or width as needed. 11 | 12 | ## Installation 13 | 14 | RZIntrinsicContentSizeTextView is available through [CocoaPods](http://cocoapods.org). To install 15 | it, simply add the following line to your Podfile: 16 | 17 | pod 'RZIntrinsicContentSizeTextView' 18 | 19 | ## Usage 20 | 21 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 22 | 23 | ## Basic Overview 24 | ----------------- 25 | ### Placeholder 26 | 27 | The placeholder interface is similar to that of a UITextField. 28 | 29 | .placeholder text of the placeholder label 30 | .placeholderTextColor textColor of the placeholder label 31 | .atributedPlaceholer attributedString for the placeholder label. 32 | 33 | If you need more fine grained control over how the placeholder looks you can use the `.attributedPlaceholder` 34 | **Note:** the size of the textview does not take into account a different font then the `.font` property. For the time being it is encouraged that these two fonts be equal 35 | 36 | ### Size Changing 37 | 38 | You should be able to drag and drop this in a xib or initialize it progromatically and have it work. As long as it has a width specified either directly or by it's layout. This will take into account the minimum and maximum constraints when determining the height, to neither get to small nor too large. 39 | 40 | .heightPriority the priority on the height constraint of the textview. Default is 999.0f 41 | 42 | **Note:** the height priority may need to be altered if you have other constraints outside of the textview that will effect it's height. 43 | 44 | 45 | By default the textview will try and animate by setting it's height and calling `layoutIfNeeded` on it's superview. However, if you need to override this you can use the `.sizeChangeDelegate` of protocol `RZIntrinsicContentSizeTextViewSizeChangedDelegate` 46 | 47 | #### RZIntrinsicContentSizeTextViewSizeChangedDelegate 48 | 49 | ```objc 50 | // Determine's whether or not the textview should animate it's size change 51 | - (BOOL)intrinsicTextView:shouldAnimateToSize: 52 | 53 | // The UIView that is going to get layoutIfNeeded called on it 54 | - (UIView *)intrinsicTextViewLayoutView: 55 | ``` 56 | 57 | If you don't want to animate any animations you can do this by returning false from `intrinsicTextView:shouldAnimateToSize` 58 | 59 | ```objc 60 | - (BOOL)intrinsicTextView:(RZIntrinsicContentSizeTextView *)textView shouldAnimateToSize:(CGSize)toSize 61 | { 62 | return NO; 63 | } 64 | ``` 65 | 66 | If you need to change the view that is calling layoutIfNeeded 67 | 68 | ```objc 69 | - (UIView *)intrinsicTextViewLayoutView:(RZIntrinsicContentSizeTextView *)textView 70 | { 71 | return self.view; 72 | } 73 | ``` 74 | 75 | This should only be used if the text view wants to animate and is getting odd animations. The most common case for this is when the text view is in a container. You will need to call `layoutIfNeeded` on the container's superview during the animation so the container will also animate its layout changing. 76 | 77 | 78 | ## Basic Use 79 | ------------- 80 | 81 | This is the basic use case code. Where the textview is pinned to the bottom of the view and has a minimum of 40.0f height and maximum of 100.0f 82 | 83 | ```objc 84 | // add textview to view 85 | self.textView = [[RZIntrinsicContentSizeTextView alloc] initWithFrame:CGRectZero]; 86 | self.textView.translatesAutoresizingMaskIntoConstraints = NO; 87 | [self.view addSubview:self.textView]; 88 | 89 | // set textview attributes 90 | self.textView.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 91 | 92 | // set placeholder attributes 93 | self.textView.placeholder = @"Hey hey hey"; 94 | self.textView.placeholderTextColor = [UIColor redColor]; 95 | 96 | // Pin the textview to the bottom of the view 97 | NSDictionary *views = NSDictionaryOfVariableBindings(_textView,self.view); 98 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_textView]|" 99 | options:0 100 | metrics:nil 101 | views:views]]; 102 | self.bottomConstraint = [NSLayoutConstraint constraintWithItem:self.view 103 | attribute:NSLayoutAttributeBottom 104 | relatedBy:NSLayoutRelationEqual 105 | toItem:self.textView 106 | attribute:NSLayoutAttributeBottom 107 | multiplier:1.0f 108 | constant:0.0f]; 109 | [self.view addConstraint:self.bottomConstraint]; 110 | 111 | // set min/max constraints 112 | NSLayoutConstraint *minHeightConstraint = [NSLayoutConstraint constraintWithItem:self.textView 113 | attribute:NSLayoutAttributeHeight 114 | relatedBy:NSLayoutRelationGreaterThanOrEqual 115 | toItem:nil 116 | attribute:NSLayoutAttributeNotAnAttribute 117 | multiplier:1.0f 118 | constant:40.0f]; 119 | [self.textView addConstraint:minHeightConstraint]; 120 | 121 | NSLayoutConstraint *maxHeightConstraint = [NSLayoutConstraint constraintWithItem:self.textView 122 | attribute:NSLayoutAttributeHeight 123 | relatedBy:NSLayoutRelationLessThanOrEqual 124 | toItem:nil 125 | attribute:NSLayoutAttributeNotAnAttribute 126 | multiplier:1.0f 127 | constant:100.0f]; 128 | [self.textView addConstraint:maxHeightConstraint]; 129 | ``` 130 | 131 | 132 | ## Author 133 | 134 | [Derek Ostrander](https://github.com/dostrander), djostran@gmail.com, [@_derko](http://twitter.com/_derko) 135 | 136 | ## Contributors 137 | 138 | [John Stricker](https://github.com/jatraiz), john.stricker@raizlabs.com 139 | 140 | 141 | ## License 142 | 143 | RZIntrinsicContentSizeTextView is available under the MIT license. See the LICENSE file for more info. 144 | -------------------------------------------------------------------------------- /RZIntrinsicContentSizeTextView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint RZIntrinsicContentSizeTextView.podspec' to ensure this is a 3 | # valid spec and remove all comments before submitting the spec. 4 | # 5 | # Any lines starting with a # are optional, but encouraged 6 | # 7 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 8 | # 9 | 10 | Pod::Spec.new do |s| 11 | s.name = "RZIntrinsicContentSizeTextView" 12 | s.version = "0.1.1" 13 | s.summary = "RZIntrinsicContentSizeTextView is a UITextView that grows dynamically in height." 14 | s.homepage = "https://github.com/Raizlabs/RZIntrinsicContentSizeTextView.git" 15 | s.license = 'MIT' 16 | s.author = { "Derek Ostrander" => "djostran@gmail.com" } 17 | s.source = { :git => "https://github.com/Raizlabs/RZIntrinsicContentSizeTextView.git", :tag => s.version.to_s } 18 | 19 | s.platform = :ios, '8.0' 20 | s.requires_arc = true 21 | 22 | s.source_files = 'Pod/**/*' 23 | 24 | s.public_header_files = 'Pod/Classes/**/*.h' 25 | end 26 | --------------------------------------------------------------------------------