├── .DS_Store ├── .gitignore ├── LICENSE ├── PQDrawTest ├── .DS_Store ├── PQDrawTest.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── PQDrawTest │ ├── 16.png │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── 222.imageset │ │ │ ├── 222.png │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── CellModel.h │ ├── CellModel.m │ ├── Draw.plist │ ├── DrawCircleViewcontroller.h │ ├── DrawCircleViewcontroller.m │ ├── DrawCircletView.h │ ├── DrawCircletView.m │ ├── DrawDownloadView.h │ ├── DrawDownloadView.m │ ├── DrawDownloadViewcontroller.h │ ├── DrawDownloadViewcontroller.m │ ├── DrawGradientController.h │ ├── DrawGradientController.m │ ├── DrawImageView.h │ ├── DrawImageView.m │ ├── DrawImageViewcontroller.h │ ├── DrawImageViewcontroller.m │ ├── DrawLineColorView.h │ ├── DrawLineColorView.m │ ├── DrawLineColorViewcontroller.h │ ├── DrawLineColorViewcontroller.m │ ├── DrawLineView.h │ ├── DrawLineView.m │ ├── DrawLineViewcontroller.h │ ├── DrawLineViewcontroller.m │ ├── DrawRectView.h │ ├── DrawRectView.m │ ├── DrawRectViewcontroller.h │ ├── DrawRectViewcontroller.m │ ├── DrawTextViewcontroller.h │ ├── DrawTextViewcontroller.m │ ├── DrawTexttView.h │ ├── DrawTexttView.m │ ├── ImageAddWaterImageViewcontroller.h │ ├── ImageAddWaterImageViewcontroller.m │ ├── ImageAddWaterTextViewcontroller.h │ ├── ImageAddWaterTextViewcontroller.m │ ├── ImageClipCircleAndBorderViewcontroller.h │ ├── ImageClipCircleAndBorderViewcontroller.m │ ├── ImageClipCircleViewcontroller.h │ ├── ImageClipCircleViewcontroller.m │ ├── ImageClipRectImageViewcontroller.h │ ├── ImageClipRectImageViewcontroller.m │ ├── ImageContextViewcontroller.h │ ├── ImageContextViewcontroller.m │ ├── ImageCutViewViewcontroller.h │ ├── ImageCutViewViewcontroller.m │ ├── ImageWipeViewcontroller.h │ ├── ImageWipeViewcontroller.m │ ├── Info.plist │ ├── LineView.h │ ├── LineView.m │ ├── PQTBDataSource.h │ ├── PQTBDataSource.m │ ├── PQTBDelegate.h │ ├── PQTBDelegate.m │ ├── PQWipeView.h │ ├── PQWipeView.m │ ├── PQWipeView.xib │ ├── SectionModel.h │ ├── SectionModel.m │ ├── UIImage+PQImage.h │ ├── UIImage+PQImage.m │ ├── UIView+pgqViewExtension.h │ ├── UIView+pgqViewExtension.m │ ├── ViewController.h │ ├── ViewController.m │ ├── back.jpg │ ├── fore.jpg │ ├── jiantou.png │ └── main.m ├── PQDrawTestTests │ ├── Info.plist │ └── PQDrawTestTests.m └── PQDrawTestUITests │ ├── Info.plist │ └── PQDrawTestUITests.m └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /PQDrawTest/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/.DS_Store -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 60FB92601D61E94600CBAFDD /* PQWipeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 60FB925F1D61E94600CBAFDD /* PQWipeView.m */; }; 11 | 60FB92621D61E9FD00CBAFDD /* PQWipeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 60FB92611D61E9FD00CBAFDD /* PQWipeView.xib */; }; 12 | 813E6A691D614FAB0032C575 /* ImageAddWaterImageViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 813E6A681D614FAB0032C575 /* ImageAddWaterImageViewcontroller.m */; }; 13 | 813E6A6C1D614FE60032C575 /* ImageAddWaterTextViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 813E6A6B1D614FE60032C575 /* ImageAddWaterTextViewcontroller.m */; }; 14 | 813E6A6F1D6150200032C575 /* ImageClipCircleViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 813E6A6E1D6150200032C575 /* ImageClipCircleViewcontroller.m */; }; 15 | 813E6A721D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 813E6A711D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.m */; }; 16 | 818147F91D5EAC5E00346206 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 818147F81D5EAC5E00346206 /* main.m */; }; 17 | 818147FC1D5EAC5E00346206 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 818147FB1D5EAC5E00346206 /* AppDelegate.m */; }; 18 | 818147FF1D5EAC5E00346206 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 818147FE1D5EAC5E00346206 /* ViewController.m */; }; 19 | 818148021D5EAC5E00346206 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818148001D5EAC5E00346206 /* Main.storyboard */; }; 20 | 818148041D5EAC5E00346206 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 818148031D5EAC5E00346206 /* Assets.xcassets */; }; 21 | 818148071D5EAC5E00346206 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 818148051D5EAC5E00346206 /* LaunchScreen.storyboard */; }; 22 | 818148121D5EAC5E00346206 /* PQDrawTestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148111D5EAC5E00346206 /* PQDrawTestTests.m */; }; 23 | 8181481D1D5EAC5E00346206 /* PQDrawTestUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181481C1D5EAC5E00346206 /* PQDrawTestUITests.m */; }; 24 | 8181482E1D5EACB900346206 /* PQTBDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181482D1D5EACB900346206 /* PQTBDataSource.m */; }; 25 | 818148301D5EACE100346206 /* Draw.plist in Resources */ = {isa = PBXBuildFile; fileRef = 8181482F1D5EACE100346206 /* Draw.plist */; }; 26 | 818148351D5EAF6F00346206 /* DrawLineViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148341D5EAF6F00346206 /* DrawLineViewcontroller.m */; }; 27 | 818148381D5EAF7B00346206 /* DrawRectViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148371D5EAF7B00346206 /* DrawRectViewcontroller.m */; }; 28 | 8181483B1D5EAF8D00346206 /* DrawCircleViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181483A1D5EAF8D00346206 /* DrawCircleViewcontroller.m */; }; 29 | 8181483E1D5EAF9A00346206 /* DrawTextViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181483D1D5EAF9A00346206 /* DrawTextViewcontroller.m */; }; 30 | 818148411D5EAFAA00346206 /* DrawImageViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148401D5EAFAA00346206 /* DrawImageViewcontroller.m */; }; 31 | 8181484C1D5EB0A400346206 /* DrawLineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181484B1D5EB0A400346206 /* DrawLineView.m */; }; 32 | 8181484F1D5EB0B200346206 /* DrawRectView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181484E1D5EB0B200346206 /* DrawRectView.m */; }; 33 | 818148521D5EB0BD00346206 /* DrawCircletView.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148511D5EB0BD00346206 /* DrawCircletView.m */; }; 34 | 818148551D5EB0C600346206 /* DrawTexttView.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148541D5EB0C600346206 /* DrawTexttView.m */; }; 35 | 818148581D5EB0D600346206 /* DrawImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148571D5EB0D600346206 /* DrawImageView.m */; }; 36 | 818148601D5EB34A00346206 /* CellModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181485B1D5EB34A00346206 /* CellModel.m */; }; 37 | 818148611D5EB34A00346206 /* SectionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181485D1D5EB34A00346206 /* SectionModel.m */; }; 38 | 818148621D5EB34A00346206 /* UIView+pgqViewExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181485F1D5EB34A00346206 /* UIView+pgqViewExtension.m */; }; 39 | 818148651D5EBAD700346206 /* PQTBDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148641D5EBAD700346206 /* PQTBDelegate.m */; }; 40 | 818148671D5EF25700346206 /* 222.png in Resources */ = {isa = PBXBuildFile; fileRef = 818148661D5EF25700346206 /* 222.png */; }; 41 | 8181486A1D5EF49000346206 /* DrawLineColorViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148691D5EF49000346206 /* DrawLineColorViewcontroller.m */; }; 42 | 8181486D1D5EF4A400346206 /* DrawDownloadViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181486C1D5EF4A400346206 /* DrawDownloadViewcontroller.m */; }; 43 | 818148701D5EF50800346206 /* DrawDownloadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8181486F1D5EF50800346206 /* DrawDownloadView.m */; }; 44 | 818148731D5EF51700346206 /* DrawLineColorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148721D5EF51700346206 /* DrawLineColorView.m */; }; 45 | 818148761D5F272100346206 /* ImageContextViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148751D5F272100346206 /* ImageContextViewcontroller.m */; }; 46 | 818148791D5F273900346206 /* UIImage+PQImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 818148781D5F273900346206 /* UIImage+PQImage.m */; }; 47 | 81F45D1D1D61688A00090568 /* ImageCutViewViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F45D1C1D61688A00090568 /* ImageCutViewViewcontroller.m */; }; 48 | 81F45D201D6170EB00090568 /* ImageWipeViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F45D1F1D6170EB00090568 /* ImageWipeViewcontroller.m */; }; 49 | 81F45D241D61717600090568 /* fore.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 81F45D221D61717600090568 /* fore.jpg */; }; 50 | 81F45D261D61729500090568 /* back.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 81F45D251D61729500090568 /* back.jpg */; }; 51 | 81FD2D0C1D619F060081C061 /* ImageClipRectImageViewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 81FD2D0B1D619F060081C061 /* ImageClipRectImageViewcontroller.m */; }; 52 | 81FD2D131D61AD770081C061 /* 16.png in Resources */ = {isa = PBXBuildFile; fileRef = 81FD2D121D61AD770081C061 /* 16.png */; }; 53 | 81FD2D171D61B2240081C061 /* jiantou.png in Resources */ = {isa = PBXBuildFile; fileRef = 81FD2D161D61B2240081C061 /* jiantou.png */; }; 54 | 8FE387251FDE1F0300A15F5C /* DrawGradientController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FE387241FDE1F0300A15F5C /* DrawGradientController.m */; }; 55 | 8FE387281FDE1F5600A15F5C /* LineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FE387271FDE1F5600A15F5C /* LineView.m */; }; 56 | /* End PBXBuildFile section */ 57 | 58 | /* Begin PBXContainerItemProxy section */ 59 | 8181480E1D5EAC5E00346206 /* PBXContainerItemProxy */ = { 60 | isa = PBXContainerItemProxy; 61 | containerPortal = 818147EC1D5EAC5E00346206 /* Project object */; 62 | proxyType = 1; 63 | remoteGlobalIDString = 818147F31D5EAC5E00346206; 64 | remoteInfo = PQDrawTest; 65 | }; 66 | 818148191D5EAC5E00346206 /* PBXContainerItemProxy */ = { 67 | isa = PBXContainerItemProxy; 68 | containerPortal = 818147EC1D5EAC5E00346206 /* Project object */; 69 | proxyType = 1; 70 | remoteGlobalIDString = 818147F31D5EAC5E00346206; 71 | remoteInfo = PQDrawTest; 72 | }; 73 | /* End PBXContainerItemProxy section */ 74 | 75 | /* Begin PBXFileReference section */ 76 | 60FB925E1D61E94600CBAFDD /* PQWipeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PQWipeView.h; sourceTree = ""; }; 77 | 60FB925F1D61E94600CBAFDD /* PQWipeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PQWipeView.m; sourceTree = ""; }; 78 | 60FB92611D61E9FD00CBAFDD /* PQWipeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PQWipeView.xib; sourceTree = ""; }; 79 | 813E6A671D614FAB0032C575 /* ImageAddWaterImageViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageAddWaterImageViewcontroller.h; sourceTree = ""; }; 80 | 813E6A681D614FAB0032C575 /* ImageAddWaterImageViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageAddWaterImageViewcontroller.m; sourceTree = ""; }; 81 | 813E6A6A1D614FE60032C575 /* ImageAddWaterTextViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageAddWaterTextViewcontroller.h; sourceTree = ""; }; 82 | 813E6A6B1D614FE60032C575 /* ImageAddWaterTextViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageAddWaterTextViewcontroller.m; sourceTree = ""; }; 83 | 813E6A6D1D6150200032C575 /* ImageClipCircleViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageClipCircleViewcontroller.h; sourceTree = ""; }; 84 | 813E6A6E1D6150200032C575 /* ImageClipCircleViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageClipCircleViewcontroller.m; sourceTree = ""; }; 85 | 813E6A701D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageClipCircleAndBorderViewcontroller.h; sourceTree = ""; }; 86 | 813E6A711D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageClipCircleAndBorderViewcontroller.m; sourceTree = ""; }; 87 | 818147F41D5EAC5E00346206 /* PQDrawTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PQDrawTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 88 | 818147F81D5EAC5E00346206 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 89 | 818147FA1D5EAC5E00346206 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 90 | 818147FB1D5EAC5E00346206 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 91 | 818147FD1D5EAC5E00346206 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 92 | 818147FE1D5EAC5E00346206 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 93 | 818148011D5EAC5E00346206 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 94 | 818148031D5EAC5E00346206 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 95 | 818148061D5EAC5E00346206 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 96 | 818148081D5EAC5E00346206 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 97 | 8181480D1D5EAC5E00346206 /* PQDrawTestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PQDrawTestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 98 | 818148111D5EAC5E00346206 /* PQDrawTestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PQDrawTestTests.m; sourceTree = ""; }; 99 | 818148131D5EAC5E00346206 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 100 | 818148181D5EAC5E00346206 /* PQDrawTestUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PQDrawTestUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 101 | 8181481C1D5EAC5E00346206 /* PQDrawTestUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PQDrawTestUITests.m; sourceTree = ""; }; 102 | 8181481E1D5EAC5E00346206 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 103 | 8181482C1D5EACB900346206 /* PQTBDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PQTBDataSource.h; sourceTree = ""; }; 104 | 8181482D1D5EACB900346206 /* PQTBDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PQTBDataSource.m; sourceTree = ""; }; 105 | 8181482F1D5EACE100346206 /* Draw.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Draw.plist; sourceTree = ""; }; 106 | 818148331D5EAF6F00346206 /* DrawLineViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawLineViewcontroller.h; sourceTree = ""; }; 107 | 818148341D5EAF6F00346206 /* DrawLineViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawLineViewcontroller.m; sourceTree = ""; }; 108 | 818148361D5EAF7B00346206 /* DrawRectViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawRectViewcontroller.h; sourceTree = ""; }; 109 | 818148371D5EAF7B00346206 /* DrawRectViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawRectViewcontroller.m; sourceTree = ""; }; 110 | 818148391D5EAF8D00346206 /* DrawCircleViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawCircleViewcontroller.h; sourceTree = ""; }; 111 | 8181483A1D5EAF8D00346206 /* DrawCircleViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawCircleViewcontroller.m; sourceTree = ""; }; 112 | 8181483C1D5EAF9A00346206 /* DrawTextViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTextViewcontroller.h; sourceTree = ""; }; 113 | 8181483D1D5EAF9A00346206 /* DrawTextViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTextViewcontroller.m; sourceTree = ""; }; 114 | 8181483F1D5EAFAA00346206 /* DrawImageViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawImageViewcontroller.h; sourceTree = ""; }; 115 | 818148401D5EAFAA00346206 /* DrawImageViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawImageViewcontroller.m; sourceTree = ""; }; 116 | 8181484A1D5EB0A400346206 /* DrawLineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawLineView.h; sourceTree = ""; }; 117 | 8181484B1D5EB0A400346206 /* DrawLineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawLineView.m; sourceTree = ""; }; 118 | 8181484D1D5EB0B200346206 /* DrawRectView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawRectView.h; sourceTree = ""; }; 119 | 8181484E1D5EB0B200346206 /* DrawRectView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawRectView.m; sourceTree = ""; }; 120 | 818148501D5EB0BD00346206 /* DrawCircletView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawCircletView.h; sourceTree = ""; }; 121 | 818148511D5EB0BD00346206 /* DrawCircletView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawCircletView.m; sourceTree = ""; }; 122 | 818148531D5EB0C600346206 /* DrawTexttView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTexttView.h; sourceTree = ""; }; 123 | 818148541D5EB0C600346206 /* DrawTexttView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTexttView.m; sourceTree = ""; }; 124 | 818148561D5EB0D600346206 /* DrawImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawImageView.h; sourceTree = ""; }; 125 | 818148571D5EB0D600346206 /* DrawImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawImageView.m; sourceTree = ""; }; 126 | 8181485A1D5EB34A00346206 /* CellModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CellModel.h; sourceTree = ""; }; 127 | 8181485B1D5EB34A00346206 /* CellModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CellModel.m; sourceTree = ""; }; 128 | 8181485C1D5EB34A00346206 /* SectionModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SectionModel.h; sourceTree = ""; }; 129 | 8181485D1D5EB34A00346206 /* SectionModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SectionModel.m; sourceTree = ""; }; 130 | 8181485E1D5EB34A00346206 /* UIView+pgqViewExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+pgqViewExtension.h"; sourceTree = ""; }; 131 | 8181485F1D5EB34A00346206 /* UIView+pgqViewExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+pgqViewExtension.m"; sourceTree = ""; }; 132 | 818148631D5EBAD700346206 /* PQTBDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PQTBDelegate.h; sourceTree = ""; }; 133 | 818148641D5EBAD700346206 /* PQTBDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PQTBDelegate.m; sourceTree = ""; }; 134 | 818148661D5EF25700346206 /* 222.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 222.png; path = Assets.xcassets/222.imageset/222.png; sourceTree = ""; }; 135 | 818148681D5EF49000346206 /* DrawLineColorViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawLineColorViewcontroller.h; sourceTree = ""; }; 136 | 818148691D5EF49000346206 /* DrawLineColorViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawLineColorViewcontroller.m; sourceTree = ""; }; 137 | 8181486B1D5EF4A400346206 /* DrawDownloadViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawDownloadViewcontroller.h; sourceTree = ""; }; 138 | 8181486C1D5EF4A400346206 /* DrawDownloadViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawDownloadViewcontroller.m; sourceTree = ""; }; 139 | 8181486E1D5EF50800346206 /* DrawDownloadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawDownloadView.h; sourceTree = ""; }; 140 | 8181486F1D5EF50800346206 /* DrawDownloadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawDownloadView.m; sourceTree = ""; }; 141 | 818148711D5EF51700346206 /* DrawLineColorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawLineColorView.h; sourceTree = ""; }; 142 | 818148721D5EF51700346206 /* DrawLineColorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawLineColorView.m; sourceTree = ""; }; 143 | 818148741D5F272100346206 /* ImageContextViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageContextViewcontroller.h; sourceTree = ""; }; 144 | 818148751D5F272100346206 /* ImageContextViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageContextViewcontroller.m; sourceTree = ""; }; 145 | 818148771D5F273900346206 /* UIImage+PQImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+PQImage.h"; sourceTree = ""; }; 146 | 818148781D5F273900346206 /* UIImage+PQImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+PQImage.m"; sourceTree = ""; }; 147 | 81F45D1B1D61688A00090568 /* ImageCutViewViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageCutViewViewcontroller.h; sourceTree = ""; }; 148 | 81F45D1C1D61688A00090568 /* ImageCutViewViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageCutViewViewcontroller.m; sourceTree = ""; }; 149 | 81F45D1E1D6170EB00090568 /* ImageWipeViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageWipeViewcontroller.h; sourceTree = ""; }; 150 | 81F45D1F1D6170EB00090568 /* ImageWipeViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageWipeViewcontroller.m; sourceTree = ""; }; 151 | 81F45D221D61717600090568 /* fore.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = fore.jpg; sourceTree = ""; }; 152 | 81F45D251D61729500090568 /* back.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = back.jpg; sourceTree = ""; }; 153 | 81FD2D0A1D619F060081C061 /* ImageClipRectImageViewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageClipRectImageViewcontroller.h; sourceTree = ""; }; 154 | 81FD2D0B1D619F060081C061 /* ImageClipRectImageViewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageClipRectImageViewcontroller.m; sourceTree = ""; }; 155 | 81FD2D121D61AD770081C061 /* 16.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 16.png; sourceTree = ""; }; 156 | 81FD2D161D61B2240081C061 /* jiantou.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = jiantou.png; sourceTree = ""; }; 157 | 8FE387231FDE1F0300A15F5C /* DrawGradientController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DrawGradientController.h; sourceTree = ""; }; 158 | 8FE387241FDE1F0300A15F5C /* DrawGradientController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DrawGradientController.m; sourceTree = ""; }; 159 | 8FE387261FDE1F5600A15F5C /* LineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineView.h; sourceTree = ""; }; 160 | 8FE387271FDE1F5600A15F5C /* LineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LineView.m; sourceTree = ""; }; 161 | /* End PBXFileReference section */ 162 | 163 | /* Begin PBXFrameworksBuildPhase section */ 164 | 818147F11D5EAC5E00346206 /* Frameworks */ = { 165 | isa = PBXFrameworksBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | ); 169 | runOnlyForDeploymentPostprocessing = 0; 170 | }; 171 | 8181480A1D5EAC5E00346206 /* Frameworks */ = { 172 | isa = PBXFrameworksBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | 818148151D5EAC5E00346206 /* Frameworks */ = { 179 | isa = PBXFrameworksBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | }; 185 | /* End PBXFrameworksBuildPhase section */ 186 | 187 | /* Begin PBXGroup section */ 188 | 818147EB1D5EAC5E00346206 = { 189 | isa = PBXGroup; 190 | children = ( 191 | 818147F61D5EAC5E00346206 /* PQDrawTest */, 192 | 818148101D5EAC5E00346206 /* PQDrawTestTests */, 193 | 8181481B1D5EAC5E00346206 /* PQDrawTestUITests */, 194 | 818147F51D5EAC5E00346206 /* Products */, 195 | ); 196 | sourceTree = ""; 197 | }; 198 | 818147F51D5EAC5E00346206 /* Products */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | 818147F41D5EAC5E00346206 /* PQDrawTest.app */, 202 | 8181480D1D5EAC5E00346206 /* PQDrawTestTests.xctest */, 203 | 818148181D5EAC5E00346206 /* PQDrawTestUITests.xctest */, 204 | ); 205 | name = Products; 206 | sourceTree = ""; 207 | }; 208 | 818147F61D5EAC5E00346206 /* PQDrawTest */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 818148421D5EAFB000346206 /* View */, 212 | 8181482B1D5EAC9700346206 /* others */, 213 | 8181482A1D5EAC8800346206 /* Controllers */, 214 | 818147F71D5EAC5E00346206 /* Supporting Files */, 215 | ); 216 | path = PQDrawTest; 217 | sourceTree = ""; 218 | }; 219 | 818147F71D5EAC5E00346206 /* Supporting Files */ = { 220 | isa = PBXGroup; 221 | children = ( 222 | 818147F81D5EAC5E00346206 /* main.m */, 223 | ); 224 | name = "Supporting Files"; 225 | sourceTree = ""; 226 | }; 227 | 818148101D5EAC5E00346206 /* PQDrawTestTests */ = { 228 | isa = PBXGroup; 229 | children = ( 230 | 818148111D5EAC5E00346206 /* PQDrawTestTests.m */, 231 | 818148131D5EAC5E00346206 /* Info.plist */, 232 | ); 233 | path = PQDrawTestTests; 234 | sourceTree = ""; 235 | }; 236 | 8181481B1D5EAC5E00346206 /* PQDrawTestUITests */ = { 237 | isa = PBXGroup; 238 | children = ( 239 | 8181481C1D5EAC5E00346206 /* PQDrawTestUITests.m */, 240 | 8181481E1D5EAC5E00346206 /* Info.plist */, 241 | ); 242 | path = PQDrawTestUITests; 243 | sourceTree = ""; 244 | }; 245 | 8181482A1D5EAC8800346206 /* Controllers */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | 818148591D5EB29A00346206 /* ViewController */, 249 | 818148321D5EAF3000346206 /* ImageContext */, 250 | 818148311D5EAF2700346206 /* Draw */, 251 | ); 252 | name = Controllers; 253 | sourceTree = ""; 254 | }; 255 | 8181482B1D5EAC9700346206 /* others */ = { 256 | isa = PBXGroup; 257 | children = ( 258 | 818147FA1D5EAC5E00346206 /* AppDelegate.h */, 259 | 818147FB1D5EAC5E00346206 /* AppDelegate.m */, 260 | 818148001D5EAC5E00346206 /* Main.storyboard */, 261 | 818148031D5EAC5E00346206 /* Assets.xcassets */, 262 | 818148051D5EAC5E00346206 /* LaunchScreen.storyboard */, 263 | 818148081D5EAC5E00346206 /* Info.plist */, 264 | ); 265 | name = others; 266 | sourceTree = ""; 267 | }; 268 | 818148311D5EAF2700346206 /* Draw */ = { 269 | isa = PBXGroup; 270 | children = ( 271 | 818148331D5EAF6F00346206 /* DrawLineViewcontroller.h */, 272 | 818148341D5EAF6F00346206 /* DrawLineViewcontroller.m */, 273 | 818148361D5EAF7B00346206 /* DrawRectViewcontroller.h */, 274 | 818148371D5EAF7B00346206 /* DrawRectViewcontroller.m */, 275 | 818148391D5EAF8D00346206 /* DrawCircleViewcontroller.h */, 276 | 8181483A1D5EAF8D00346206 /* DrawCircleViewcontroller.m */, 277 | 8181483C1D5EAF9A00346206 /* DrawTextViewcontroller.h */, 278 | 8181483D1D5EAF9A00346206 /* DrawTextViewcontroller.m */, 279 | 8181483F1D5EAFAA00346206 /* DrawImageViewcontroller.h */, 280 | 818148401D5EAFAA00346206 /* DrawImageViewcontroller.m */, 281 | 818148681D5EF49000346206 /* DrawLineColorViewcontroller.h */, 282 | 818148691D5EF49000346206 /* DrawLineColorViewcontroller.m */, 283 | 8181486B1D5EF4A400346206 /* DrawDownloadViewcontroller.h */, 284 | 8181486C1D5EF4A400346206 /* DrawDownloadViewcontroller.m */, 285 | 8FE387231FDE1F0300A15F5C /* DrawGradientController.h */, 286 | 8FE387241FDE1F0300A15F5C /* DrawGradientController.m */, 287 | ); 288 | name = Draw; 289 | sourceTree = ""; 290 | }; 291 | 818148321D5EAF3000346206 /* ImageContext */ = { 292 | isa = PBXGroup; 293 | children = ( 294 | 81FD2D161D61B2240081C061 /* jiantou.png */, 295 | 81FD2D121D61AD770081C061 /* 16.png */, 296 | 81F45D251D61729500090568 /* back.jpg */, 297 | 81F45D221D61717600090568 /* fore.jpg */, 298 | 818148741D5F272100346206 /* ImageContextViewcontroller.h */, 299 | 818148751D5F272100346206 /* ImageContextViewcontroller.m */, 300 | 818148771D5F273900346206 /* UIImage+PQImage.h */, 301 | 818148781D5F273900346206 /* UIImage+PQImage.m */, 302 | 813E6A671D614FAB0032C575 /* ImageAddWaterImageViewcontroller.h */, 303 | 813E6A681D614FAB0032C575 /* ImageAddWaterImageViewcontroller.m */, 304 | 813E6A6A1D614FE60032C575 /* ImageAddWaterTextViewcontroller.h */, 305 | 813E6A6B1D614FE60032C575 /* ImageAddWaterTextViewcontroller.m */, 306 | 813E6A6D1D6150200032C575 /* ImageClipCircleViewcontroller.h */, 307 | 813E6A6E1D6150200032C575 /* ImageClipCircleViewcontroller.m */, 308 | 813E6A701D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.h */, 309 | 813E6A711D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.m */, 310 | 81F45D1B1D61688A00090568 /* ImageCutViewViewcontroller.h */, 311 | 81F45D1C1D61688A00090568 /* ImageCutViewViewcontroller.m */, 312 | 81F45D1E1D6170EB00090568 /* ImageWipeViewcontroller.h */, 313 | 81F45D1F1D6170EB00090568 /* ImageWipeViewcontroller.m */, 314 | 81FD2D0A1D619F060081C061 /* ImageClipRectImageViewcontroller.h */, 315 | 81FD2D0B1D619F060081C061 /* ImageClipRectImageViewcontroller.m */, 316 | 60FB925E1D61E94600CBAFDD /* PQWipeView.h */, 317 | 60FB925F1D61E94600CBAFDD /* PQWipeView.m */, 318 | 60FB92611D61E9FD00CBAFDD /* PQWipeView.xib */, 319 | ); 320 | name = ImageContext; 321 | sourceTree = ""; 322 | }; 323 | 818148421D5EAFB000346206 /* View */ = { 324 | isa = PBXGroup; 325 | children = ( 326 | 818148661D5EF25700346206 /* 222.png */, 327 | 818148491D5EB09400346206 /* Draw */, 328 | ); 329 | name = View; 330 | sourceTree = ""; 331 | }; 332 | 818148491D5EB09400346206 /* Draw */ = { 333 | isa = PBXGroup; 334 | children = ( 335 | 8FE387261FDE1F5600A15F5C /* LineView.h */, 336 | 8FE387271FDE1F5600A15F5C /* LineView.m */, 337 | 8181484A1D5EB0A400346206 /* DrawLineView.h */, 338 | 8181484B1D5EB0A400346206 /* DrawLineView.m */, 339 | 8181484D1D5EB0B200346206 /* DrawRectView.h */, 340 | 8181484E1D5EB0B200346206 /* DrawRectView.m */, 341 | 818148501D5EB0BD00346206 /* DrawCircletView.h */, 342 | 818148511D5EB0BD00346206 /* DrawCircletView.m */, 343 | 818148531D5EB0C600346206 /* DrawTexttView.h */, 344 | 818148541D5EB0C600346206 /* DrawTexttView.m */, 345 | 818148561D5EB0D600346206 /* DrawImageView.h */, 346 | 818148571D5EB0D600346206 /* DrawImageView.m */, 347 | 8181486E1D5EF50800346206 /* DrawDownloadView.h */, 348 | 8181486F1D5EF50800346206 /* DrawDownloadView.m */, 349 | 818148711D5EF51700346206 /* DrawLineColorView.h */, 350 | 818148721D5EF51700346206 /* DrawLineColorView.m */, 351 | ); 352 | name = Draw; 353 | sourceTree = ""; 354 | }; 355 | 818148591D5EB29A00346206 /* ViewController */ = { 356 | isa = PBXGroup; 357 | children = ( 358 | 818148631D5EBAD700346206 /* PQTBDelegate.h */, 359 | 818148641D5EBAD700346206 /* PQTBDelegate.m */, 360 | 8181485A1D5EB34A00346206 /* CellModel.h */, 361 | 8181485B1D5EB34A00346206 /* CellModel.m */, 362 | 8181485C1D5EB34A00346206 /* SectionModel.h */, 363 | 8181485D1D5EB34A00346206 /* SectionModel.m */, 364 | 8181485E1D5EB34A00346206 /* UIView+pgqViewExtension.h */, 365 | 8181485F1D5EB34A00346206 /* UIView+pgqViewExtension.m */, 366 | 8181482C1D5EACB900346206 /* PQTBDataSource.h */, 367 | 8181482D1D5EACB900346206 /* PQTBDataSource.m */, 368 | 818147FD1D5EAC5E00346206 /* ViewController.h */, 369 | 818147FE1D5EAC5E00346206 /* ViewController.m */, 370 | 8181482F1D5EACE100346206 /* Draw.plist */, 371 | ); 372 | name = ViewController; 373 | sourceTree = ""; 374 | }; 375 | /* End PBXGroup section */ 376 | 377 | /* Begin PBXNativeTarget section */ 378 | 818147F31D5EAC5E00346206 /* PQDrawTest */ = { 379 | isa = PBXNativeTarget; 380 | buildConfigurationList = 818148211D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTest" */; 381 | buildPhases = ( 382 | 818147F01D5EAC5E00346206 /* Sources */, 383 | 818147F11D5EAC5E00346206 /* Frameworks */, 384 | 818147F21D5EAC5E00346206 /* Resources */, 385 | ); 386 | buildRules = ( 387 | ); 388 | dependencies = ( 389 | ); 390 | name = PQDrawTest; 391 | productName = PQDrawTest; 392 | productReference = 818147F41D5EAC5E00346206 /* PQDrawTest.app */; 393 | productType = "com.apple.product-type.application"; 394 | }; 395 | 8181480C1D5EAC5E00346206 /* PQDrawTestTests */ = { 396 | isa = PBXNativeTarget; 397 | buildConfigurationList = 818148241D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTestTests" */; 398 | buildPhases = ( 399 | 818148091D5EAC5E00346206 /* Sources */, 400 | 8181480A1D5EAC5E00346206 /* Frameworks */, 401 | 8181480B1D5EAC5E00346206 /* Resources */, 402 | ); 403 | buildRules = ( 404 | ); 405 | dependencies = ( 406 | 8181480F1D5EAC5E00346206 /* PBXTargetDependency */, 407 | ); 408 | name = PQDrawTestTests; 409 | productName = PQDrawTestTests; 410 | productReference = 8181480D1D5EAC5E00346206 /* PQDrawTestTests.xctest */; 411 | productType = "com.apple.product-type.bundle.unit-test"; 412 | }; 413 | 818148171D5EAC5E00346206 /* PQDrawTestUITests */ = { 414 | isa = PBXNativeTarget; 415 | buildConfigurationList = 818148271D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTestUITests" */; 416 | buildPhases = ( 417 | 818148141D5EAC5E00346206 /* Sources */, 418 | 818148151D5EAC5E00346206 /* Frameworks */, 419 | 818148161D5EAC5E00346206 /* Resources */, 420 | ); 421 | buildRules = ( 422 | ); 423 | dependencies = ( 424 | 8181481A1D5EAC5E00346206 /* PBXTargetDependency */, 425 | ); 426 | name = PQDrawTestUITests; 427 | productName = PQDrawTestUITests; 428 | productReference = 818148181D5EAC5E00346206 /* PQDrawTestUITests.xctest */; 429 | productType = "com.apple.product-type.bundle.ui-testing"; 430 | }; 431 | /* End PBXNativeTarget section */ 432 | 433 | /* Begin PBXProject section */ 434 | 818147EC1D5EAC5E00346206 /* Project object */ = { 435 | isa = PBXProject; 436 | attributes = { 437 | LastUpgradeCheck = 0730; 438 | ORGANIZATIONNAME = ios; 439 | TargetAttributes = { 440 | 818147F31D5EAC5E00346206 = { 441 | CreatedOnToolsVersion = 7.3; 442 | DevelopmentTeam = B2BXA8AH8F; 443 | }; 444 | 8181480C1D5EAC5E00346206 = { 445 | CreatedOnToolsVersion = 7.3; 446 | TestTargetID = 818147F31D5EAC5E00346206; 447 | }; 448 | 818148171D5EAC5E00346206 = { 449 | CreatedOnToolsVersion = 7.3; 450 | TestTargetID = 818147F31D5EAC5E00346206; 451 | }; 452 | }; 453 | }; 454 | buildConfigurationList = 818147EF1D5EAC5E00346206 /* Build configuration list for PBXProject "PQDrawTest" */; 455 | compatibilityVersion = "Xcode 3.2"; 456 | developmentRegion = English; 457 | hasScannedForEncodings = 0; 458 | knownRegions = ( 459 | en, 460 | Base, 461 | ); 462 | mainGroup = 818147EB1D5EAC5E00346206; 463 | productRefGroup = 818147F51D5EAC5E00346206 /* Products */; 464 | projectDirPath = ""; 465 | projectRoot = ""; 466 | targets = ( 467 | 818147F31D5EAC5E00346206 /* PQDrawTest */, 468 | 8181480C1D5EAC5E00346206 /* PQDrawTestTests */, 469 | 818148171D5EAC5E00346206 /* PQDrawTestUITests */, 470 | ); 471 | }; 472 | /* End PBXProject section */ 473 | 474 | /* Begin PBXResourcesBuildPhase section */ 475 | 818147F21D5EAC5E00346206 /* Resources */ = { 476 | isa = PBXResourcesBuildPhase; 477 | buildActionMask = 2147483647; 478 | files = ( 479 | 81FD2D131D61AD770081C061 /* 16.png in Resources */, 480 | 81F45D241D61717600090568 /* fore.jpg in Resources */, 481 | 81FD2D171D61B2240081C061 /* jiantou.png in Resources */, 482 | 818148071D5EAC5E00346206 /* LaunchScreen.storyboard in Resources */, 483 | 60FB92621D61E9FD00CBAFDD /* PQWipeView.xib in Resources */, 484 | 818148671D5EF25700346206 /* 222.png in Resources */, 485 | 818148041D5EAC5E00346206 /* Assets.xcassets in Resources */, 486 | 818148301D5EACE100346206 /* Draw.plist in Resources */, 487 | 81F45D261D61729500090568 /* back.jpg in Resources */, 488 | 818148021D5EAC5E00346206 /* Main.storyboard in Resources */, 489 | ); 490 | runOnlyForDeploymentPostprocessing = 0; 491 | }; 492 | 8181480B1D5EAC5E00346206 /* Resources */ = { 493 | isa = PBXResourcesBuildPhase; 494 | buildActionMask = 2147483647; 495 | files = ( 496 | ); 497 | runOnlyForDeploymentPostprocessing = 0; 498 | }; 499 | 818148161D5EAC5E00346206 /* Resources */ = { 500 | isa = PBXResourcesBuildPhase; 501 | buildActionMask = 2147483647; 502 | files = ( 503 | ); 504 | runOnlyForDeploymentPostprocessing = 0; 505 | }; 506 | /* End PBXResourcesBuildPhase section */ 507 | 508 | /* Begin PBXSourcesBuildPhase section */ 509 | 818147F01D5EAC5E00346206 /* Sources */ = { 510 | isa = PBXSourcesBuildPhase; 511 | buildActionMask = 2147483647; 512 | files = ( 513 | 8181486D1D5EF4A400346206 /* DrawDownloadViewcontroller.m in Sources */, 514 | 818147FF1D5EAC5E00346206 /* ViewController.m in Sources */, 515 | 818148761D5F272100346206 /* ImageContextViewcontroller.m in Sources */, 516 | 8181482E1D5EACB900346206 /* PQTBDataSource.m in Sources */, 517 | 813E6A721D6150510032C575 /* ImageClipCircleAndBorderViewcontroller.m in Sources */, 518 | 81F45D201D6170EB00090568 /* ImageWipeViewcontroller.m in Sources */, 519 | 813E6A6F1D6150200032C575 /* ImageClipCircleViewcontroller.m in Sources */, 520 | 818148791D5F273900346206 /* UIImage+PQImage.m in Sources */, 521 | 818148701D5EF50800346206 /* DrawDownloadView.m in Sources */, 522 | 818148411D5EAFAA00346206 /* DrawImageViewcontroller.m in Sources */, 523 | 818148551D5EB0C600346206 /* DrawTexttView.m in Sources */, 524 | 818148731D5EF51700346206 /* DrawLineColorView.m in Sources */, 525 | 813E6A6C1D614FE60032C575 /* ImageAddWaterTextViewcontroller.m in Sources */, 526 | 81F45D1D1D61688A00090568 /* ImageCutViewViewcontroller.m in Sources */, 527 | 818148581D5EB0D600346206 /* DrawImageView.m in Sources */, 528 | 818148381D5EAF7B00346206 /* DrawRectViewcontroller.m in Sources */, 529 | 8181484C1D5EB0A400346206 /* DrawLineView.m in Sources */, 530 | 8181483B1D5EAF8D00346206 /* DrawCircleViewcontroller.m in Sources */, 531 | 8FE387251FDE1F0300A15F5C /* DrawGradientController.m in Sources */, 532 | 818148601D5EB34A00346206 /* CellModel.m in Sources */, 533 | 818148351D5EAF6F00346206 /* DrawLineViewcontroller.m in Sources */, 534 | 813E6A691D614FAB0032C575 /* ImageAddWaterImageViewcontroller.m in Sources */, 535 | 81FD2D0C1D619F060081C061 /* ImageClipRectImageViewcontroller.m in Sources */, 536 | 818148521D5EB0BD00346206 /* DrawCircletView.m in Sources */, 537 | 818148651D5EBAD700346206 /* PQTBDelegate.m in Sources */, 538 | 8181483E1D5EAF9A00346206 /* DrawTextViewcontroller.m in Sources */, 539 | 8181484F1D5EB0B200346206 /* DrawRectView.m in Sources */, 540 | 818147FC1D5EAC5E00346206 /* AppDelegate.m in Sources */, 541 | 8FE387281FDE1F5600A15F5C /* LineView.m in Sources */, 542 | 60FB92601D61E94600CBAFDD /* PQWipeView.m in Sources */, 543 | 818147F91D5EAC5E00346206 /* main.m in Sources */, 544 | 8181486A1D5EF49000346206 /* DrawLineColorViewcontroller.m in Sources */, 545 | 818148611D5EB34A00346206 /* SectionModel.m in Sources */, 546 | 818148621D5EB34A00346206 /* UIView+pgqViewExtension.m in Sources */, 547 | ); 548 | runOnlyForDeploymentPostprocessing = 0; 549 | }; 550 | 818148091D5EAC5E00346206 /* Sources */ = { 551 | isa = PBXSourcesBuildPhase; 552 | buildActionMask = 2147483647; 553 | files = ( 554 | 818148121D5EAC5E00346206 /* PQDrawTestTests.m in Sources */, 555 | ); 556 | runOnlyForDeploymentPostprocessing = 0; 557 | }; 558 | 818148141D5EAC5E00346206 /* Sources */ = { 559 | isa = PBXSourcesBuildPhase; 560 | buildActionMask = 2147483647; 561 | files = ( 562 | 8181481D1D5EAC5E00346206 /* PQDrawTestUITests.m in Sources */, 563 | ); 564 | runOnlyForDeploymentPostprocessing = 0; 565 | }; 566 | /* End PBXSourcesBuildPhase section */ 567 | 568 | /* Begin PBXTargetDependency section */ 569 | 8181480F1D5EAC5E00346206 /* PBXTargetDependency */ = { 570 | isa = PBXTargetDependency; 571 | target = 818147F31D5EAC5E00346206 /* PQDrawTest */; 572 | targetProxy = 8181480E1D5EAC5E00346206 /* PBXContainerItemProxy */; 573 | }; 574 | 8181481A1D5EAC5E00346206 /* PBXTargetDependency */ = { 575 | isa = PBXTargetDependency; 576 | target = 818147F31D5EAC5E00346206 /* PQDrawTest */; 577 | targetProxy = 818148191D5EAC5E00346206 /* PBXContainerItemProxy */; 578 | }; 579 | /* End PBXTargetDependency section */ 580 | 581 | /* Begin PBXVariantGroup section */ 582 | 818148001D5EAC5E00346206 /* Main.storyboard */ = { 583 | isa = PBXVariantGroup; 584 | children = ( 585 | 818148011D5EAC5E00346206 /* Base */, 586 | ); 587 | name = Main.storyboard; 588 | sourceTree = ""; 589 | }; 590 | 818148051D5EAC5E00346206 /* LaunchScreen.storyboard */ = { 591 | isa = PBXVariantGroup; 592 | children = ( 593 | 818148061D5EAC5E00346206 /* Base */, 594 | ); 595 | name = LaunchScreen.storyboard; 596 | sourceTree = ""; 597 | }; 598 | /* End PBXVariantGroup section */ 599 | 600 | /* Begin XCBuildConfiguration section */ 601 | 8181481F1D5EAC5E00346206 /* Debug */ = { 602 | isa = XCBuildConfiguration; 603 | buildSettings = { 604 | ALWAYS_SEARCH_USER_PATHS = NO; 605 | CLANG_ANALYZER_NONNULL = YES; 606 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 607 | CLANG_CXX_LIBRARY = "libc++"; 608 | CLANG_ENABLE_MODULES = YES; 609 | CLANG_ENABLE_OBJC_ARC = YES; 610 | CLANG_WARN_BOOL_CONVERSION = YES; 611 | CLANG_WARN_CONSTANT_CONVERSION = YES; 612 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 613 | CLANG_WARN_EMPTY_BODY = YES; 614 | CLANG_WARN_ENUM_CONVERSION = YES; 615 | CLANG_WARN_INT_CONVERSION = YES; 616 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 617 | CLANG_WARN_UNREACHABLE_CODE = YES; 618 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 619 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 620 | COPY_PHASE_STRIP = NO; 621 | DEBUG_INFORMATION_FORMAT = dwarf; 622 | ENABLE_STRICT_OBJC_MSGSEND = YES; 623 | ENABLE_TESTABILITY = YES; 624 | GCC_C_LANGUAGE_STANDARD = gnu99; 625 | GCC_DYNAMIC_NO_PIC = NO; 626 | GCC_NO_COMMON_BLOCKS = YES; 627 | GCC_OPTIMIZATION_LEVEL = 0; 628 | GCC_PREPROCESSOR_DEFINITIONS = ( 629 | "DEBUG=1", 630 | "$(inherited)", 631 | ); 632 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 633 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 634 | GCC_WARN_UNDECLARED_SELECTOR = YES; 635 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 636 | GCC_WARN_UNUSED_FUNCTION = YES; 637 | GCC_WARN_UNUSED_VARIABLE = YES; 638 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 639 | MTL_ENABLE_DEBUG_INFO = YES; 640 | ONLY_ACTIVE_ARCH = YES; 641 | SDKROOT = iphoneos; 642 | TARGETED_DEVICE_FAMILY = "1,2"; 643 | }; 644 | name = Debug; 645 | }; 646 | 818148201D5EAC5E00346206 /* Release */ = { 647 | isa = XCBuildConfiguration; 648 | buildSettings = { 649 | ALWAYS_SEARCH_USER_PATHS = NO; 650 | CLANG_ANALYZER_NONNULL = YES; 651 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 652 | CLANG_CXX_LIBRARY = "libc++"; 653 | CLANG_ENABLE_MODULES = YES; 654 | CLANG_ENABLE_OBJC_ARC = YES; 655 | CLANG_WARN_BOOL_CONVERSION = YES; 656 | CLANG_WARN_CONSTANT_CONVERSION = YES; 657 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 658 | CLANG_WARN_EMPTY_BODY = YES; 659 | CLANG_WARN_ENUM_CONVERSION = YES; 660 | CLANG_WARN_INT_CONVERSION = YES; 661 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 662 | CLANG_WARN_UNREACHABLE_CODE = YES; 663 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 664 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 665 | COPY_PHASE_STRIP = NO; 666 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 667 | ENABLE_NS_ASSERTIONS = NO; 668 | ENABLE_STRICT_OBJC_MSGSEND = YES; 669 | GCC_C_LANGUAGE_STANDARD = gnu99; 670 | GCC_NO_COMMON_BLOCKS = YES; 671 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 672 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 673 | GCC_WARN_UNDECLARED_SELECTOR = YES; 674 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 675 | GCC_WARN_UNUSED_FUNCTION = YES; 676 | GCC_WARN_UNUSED_VARIABLE = YES; 677 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 678 | MTL_ENABLE_DEBUG_INFO = NO; 679 | SDKROOT = iphoneos; 680 | TARGETED_DEVICE_FAMILY = "1,2"; 681 | VALIDATE_PRODUCT = YES; 682 | }; 683 | name = Release; 684 | }; 685 | 818148221D5EAC5E00346206 /* Debug */ = { 686 | isa = XCBuildConfiguration; 687 | buildSettings = { 688 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 689 | DEVELOPMENT_TEAM = B2BXA8AH8F; 690 | INFOPLIST_FILE = PQDrawTest/Info.plist; 691 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 692 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 693 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTest; 694 | PRODUCT_NAME = "$(TARGET_NAME)"; 695 | }; 696 | name = Debug; 697 | }; 698 | 818148231D5EAC5E00346206 /* Release */ = { 699 | isa = XCBuildConfiguration; 700 | buildSettings = { 701 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 702 | DEVELOPMENT_TEAM = B2BXA8AH8F; 703 | INFOPLIST_FILE = PQDrawTest/Info.plist; 704 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 705 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 706 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTest; 707 | PRODUCT_NAME = "$(TARGET_NAME)"; 708 | }; 709 | name = Release; 710 | }; 711 | 818148251D5EAC5E00346206 /* Debug */ = { 712 | isa = XCBuildConfiguration; 713 | buildSettings = { 714 | BUNDLE_LOADER = "$(TEST_HOST)"; 715 | INFOPLIST_FILE = PQDrawTestTests/Info.plist; 716 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 717 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTestTests; 718 | PRODUCT_NAME = "$(TARGET_NAME)"; 719 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PQDrawTest.app/PQDrawTest"; 720 | }; 721 | name = Debug; 722 | }; 723 | 818148261D5EAC5E00346206 /* Release */ = { 724 | isa = XCBuildConfiguration; 725 | buildSettings = { 726 | BUNDLE_LOADER = "$(TEST_HOST)"; 727 | INFOPLIST_FILE = PQDrawTestTests/Info.plist; 728 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 729 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTestTests; 730 | PRODUCT_NAME = "$(TARGET_NAME)"; 731 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PQDrawTest.app/PQDrawTest"; 732 | }; 733 | name = Release; 734 | }; 735 | 818148281D5EAC5E00346206 /* Debug */ = { 736 | isa = XCBuildConfiguration; 737 | buildSettings = { 738 | INFOPLIST_FILE = PQDrawTestUITests/Info.plist; 739 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 740 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTestUITests; 741 | PRODUCT_NAME = "$(TARGET_NAME)"; 742 | TEST_TARGET_NAME = PQDrawTest; 743 | }; 744 | name = Debug; 745 | }; 746 | 818148291D5EAC5E00346206 /* Release */ = { 747 | isa = XCBuildConfiguration; 748 | buildSettings = { 749 | INFOPLIST_FILE = PQDrawTestUITests/Info.plist; 750 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 751 | PRODUCT_BUNDLE_IDENTIFIER = pq.PQDrawTestUITests; 752 | PRODUCT_NAME = "$(TARGET_NAME)"; 753 | TEST_TARGET_NAME = PQDrawTest; 754 | }; 755 | name = Release; 756 | }; 757 | /* End XCBuildConfiguration section */ 758 | 759 | /* Begin XCConfigurationList section */ 760 | 818147EF1D5EAC5E00346206 /* Build configuration list for PBXProject "PQDrawTest" */ = { 761 | isa = XCConfigurationList; 762 | buildConfigurations = ( 763 | 8181481F1D5EAC5E00346206 /* Debug */, 764 | 818148201D5EAC5E00346206 /* Release */, 765 | ); 766 | defaultConfigurationIsVisible = 0; 767 | defaultConfigurationName = Release; 768 | }; 769 | 818148211D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTest" */ = { 770 | isa = XCConfigurationList; 771 | buildConfigurations = ( 772 | 818148221D5EAC5E00346206 /* Debug */, 773 | 818148231D5EAC5E00346206 /* Release */, 774 | ); 775 | defaultConfigurationIsVisible = 0; 776 | defaultConfigurationName = Release; 777 | }; 778 | 818148241D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTestTests" */ = { 779 | isa = XCConfigurationList; 780 | buildConfigurations = ( 781 | 818148251D5EAC5E00346206 /* Debug */, 782 | 818148261D5EAC5E00346206 /* Release */, 783 | ); 784 | defaultConfigurationIsVisible = 0; 785 | defaultConfigurationName = Release; 786 | }; 787 | 818148271D5EAC5E00346206 /* Build configuration list for PBXNativeTarget "PQDrawTestUITests" */ = { 788 | isa = XCConfigurationList; 789 | buildConfigurations = ( 790 | 818148281D5EAC5E00346206 /* Debug */, 791 | 818148291D5EAC5E00346206 /* Release */, 792 | ); 793 | defaultConfigurationIsVisible = 0; 794 | defaultConfigurationName = Release; 795 | }; 796 | /* End XCConfigurationList section */ 797 | }; 798 | rootObject = 818147EC1D5EAC5E00346206 /* Project object */; 799 | } 800 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/PQDrawTest/16.png -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Assets.xcassets/222.imageset/222.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/PQDrawTest/Assets.xcassets/222.imageset/222.png -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Assets.xcassets/222.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "222.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Assets.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" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/CellModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CellModel.h 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CellModel : NSObject 12 | 13 | @property (nonatomic,copy) NSString * name; 14 | @property (nonatomic,copy) NSString * controller; 15 | 16 | + (instancetype)cellWithDict:(NSDictionary *)dict; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/CellModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // CellModel.m 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "CellModel.h" 10 | 11 | @implementation CellModel 12 | + (instancetype)cellWithDict:(NSDictionary *)dict{ 13 | CellModel * cell = [[self alloc]init]; 14 | [cell setValuesForKeysWithDictionary:dict]; 15 | return cell; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Draw.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | items 7 | 8 | 9 | name 10 | 划线 11 | controller 12 | DrawLineViewcontroller 13 | 14 | 15 | name 16 | 画矩形 17 | controller 18 | DrawRectViewcontroller 19 | 20 | 21 | name 22 | 画圆形 23 | controller 24 | DrawCircleViewcontroller 25 | 26 | 27 | name 28 | 画文字 29 | controller 30 | DrawTextViewcontroller 31 | 32 | 33 | name 34 | 画图片 35 | controller 36 | DrawImageViewcontroller 37 | 38 | 39 | name 40 | 下载进度条 41 | controller 42 | DrawDownloadViewController 43 | 44 | 45 | name 46 | 设置不同颜色的线条 47 | controller 48 | DrawLineColorViewcontroller 49 | 50 | 51 | name 52 | 绘制渐变色 53 | controller 54 | DrawGradientController 55 | 56 | 57 | section 58 | Draw 59 | 60 | 61 | items 62 | 63 | 64 | name 65 | 使用图形上下文 66 | controller 67 | ImageContextViewcontroller 68 | 69 | 70 | name 71 | 给图片添加文字水印 72 | controller 73 | ImageAddWaterTextViewcontroller 74 | 75 | 76 | name 77 | 给图片添加图片水印 78 | controller 79 | ImageAddWaterImageViewcontroller 80 | 81 | 82 | name 83 | 裁剪圆形图片 84 | controller 85 | ImageClipCircleViewcontroller 86 | 87 | 88 | name 89 | 裁剪圆形带边框图片 90 | controller 91 | ImageClipCircleAndBorderViewcontroller 92 | 93 | 94 | name 95 | 对VIew进行截取 96 | controller 97 | ImageCutViewViewcontroller 98 | 99 | 100 | name 101 | 擦除效果 102 | controller 103 | ImageWipeViewcontroller 104 | 105 | 106 | name 107 | 自定义大小图片裁剪 108 | controller 109 | ImageClipRectImageViewcontroller 110 | 111 | 112 | section 113 | 图形上下文 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawCircleViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawCircleViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawCircleViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawCircleViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawCircleViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawCircleViewcontroller.h" 10 | #import "DrawCircletView.h" 11 | @interface DrawCircleViewcontroller () 12 | 13 | @end 14 | 15 | @implementation DrawCircleViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | DrawCircletView * circle = [[DrawCircletView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 21 | circle.backgroundColor = [UIColor grayColor]; 22 | [self.view addSubview:circle]; 23 | } 24 | 25 | - (void)didReceiveMemoryWarning { 26 | [super didReceiveMemoryWarning]; 27 | // Dispose of any resources that can be recreated. 28 | } 29 | 30 | /* 31 | #pragma mark - Navigation 32 | 33 | // In a storyboard-based application, you will often want to do a little preparation before navigation 34 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 35 | // Get the new view controller using [segue destinationViewController]. 36 | // Pass the selected object to the new view controller. 37 | } 38 | */ 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawCircletView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawCircletView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawCircletView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawCircletView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawCircletView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawCircletView.h" 10 | 11 | @implementation DrawCircletView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | 19 | //1、获取当前上下文 20 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 21 | //2.描述路径 这是画椭圆的方法,大家都知道 22 | UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(10, 10, 100, 100)]; 23 | //3.添加路径到上下文 24 | CGContextAddPath(contextRef, path.CGPath); 25 | //4.设置颜色 26 | [[UIColor redColor]setFill]; 27 | //4.显示上下文 28 | CGContextFillPath(contextRef); 29 | 30 | } 31 | 32 | - (void)drawCircle{ 33 | //1、获取当前上下文 34 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 35 | //2.描述路径 36 | //ArcCenter:中心点 37 | //radius:半径 38 | //startAngle:起始角度 39 | //endAngle:结束角度 40 | //clockwise:是否逆时针 41 | UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width*0.5, self.bounds.size.height*0.5) radius:self.bounds.size.width*0.4 startAngle:0 endAngle:M_PI*2 clockwise:NO]; 42 | //3.添加路径到上下文 43 | CGContextAddPath(contextRef, path.CGPath); 44 | //4.设置颜色 45 | [[UIColor brownColor]setFill]; 46 | //4.显示上下文 显示一个实心圆 47 | // CGContextFillPath(contextRef); 48 | //显示一个空心圆,描边 49 | CGContextStrokePath(contextRef); 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawDownloadView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawDownloadView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawDownloadView : UIView 12 | 13 | //设置进度 14 | @property (nonatomic,assign) CGFloat progress; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawDownloadView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawDownloadView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawDownloadView.h" 10 | 11 | @interface DrawDownloadView () 12 | 13 | @property (weak,nonatomic) IBOutlet UILabel * textLabel; 14 | @property (nonatomic,strong) CABasicAnimation * animation; 15 | @end 16 | 17 | @implementation DrawDownloadView 18 | 19 | - (void)awakeFromNib{ 20 | self.backgroundColor = [UIColor clearColor]; 21 | } 22 | 23 | - (void)setProgress:(CGFloat)progress{ 24 | _progress = progress; 25 | 26 | _textLabel.text = [NSString stringWithFormat:@"%.2f%%",_progress*100]; 27 | _textLabel.textColor = [UIColor colorWithRed:self.progress green:0 blue:0 alpha:1]; 28 | //重绘 29 | [self setNeedsDisplay]; 30 | } 31 | 32 | 33 | 34 | // Only override drawRect: if you perform custom drawing. 35 | // An empty implementation adversely affects performance during animation. 36 | - (void)drawRect:(CGRect)rect { 37 | 38 | CGFloat startA = - M_PI_2; 39 | CGFloat endA = - M_PI_2 + self.progress * M_PI * 2; 40 | UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width*0.5, self.bounds.size.height*0.5) radius:self.bounds.size.width*0.5-10 startAngle:startA endAngle:endA clockwise:YES]; 41 | [[UIColor colorWithRed:self.progress green:(1-self.progress) blue:0 alpha:1]setStroke]; 42 | path.lineWidth = 5; 43 | [path stroke]; 44 | 45 | } 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawDownloadViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawDownloadViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawDownloadViewcontroller : UIViewController 12 | 13 | + (instancetype)loadForStoryboard; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawDownloadViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawDownloadViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawDownloadViewcontroller.h" 10 | #import "DrawDownloadView.h" 11 | @interface DrawDownloadViewcontroller () 12 | @property (weak, nonatomic) IBOutlet DrawDownloadView *downloadView; 13 | 14 | @end 15 | 16 | @implementation DrawDownloadViewcontroller 17 | 18 | + (instancetype)loadForStoryboard{ 19 | UIStoryboard * sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 20 | return [sb instantiateViewControllerWithIdentifier:@"download"]; 21 | } 22 | 23 | - (IBAction)sender:(UISlider *)sender { 24 | _downloadView.progress = sender.value; 25 | } 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view. 30 | } 31 | 32 | - (void)didReceiveMemoryWarning { 33 | [super didReceiveMemoryWarning]; 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | /* 38 | #pragma mark - Navigation 39 | 40 | // In a storyboard-based application, you will often want to do a little preparation before navigation 41 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 42 | // Get the new view controller using [segue destinationViewController]. 43 | // Pass the selected object to the new view controller. 44 | } 45 | */ 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawGradientController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawGradientController.h 3 | // PQDrawTest 4 | // 5 | // Created by pgq on 2017/12/11. 6 | // Copyright © 2017年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawGradientController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawGradientController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawGradientController.m 3 | // PQDrawTest 4 | // 5 | // Created by pgq on 2017/12/11. 6 | // Copyright © 2017年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawGradientController.h" 10 | #import "LineView.h" 11 | @interface DrawGradientController () 12 | 13 | @end 14 | 15 | @implementation DrawGradientController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | //方案一: 22 | LineView * lineView = [[LineView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]; 23 | lineView.center = self.view.center; 24 | [self.view addSubview:lineView]; 25 | 26 | //方案二: 27 | CAGradientLayer * layer = [CAGradientLayer layer]; 28 | //设置大小 29 | layer.frame = CGRectMake(0, 400, 300, 3); 30 | //设置颜色 31 | layer.colors = @[(__bridge id)[UIColor colorWithRed:204.0 / 255.0 green:224.0 / 255.0 blue:244.0 / 255.0 alpha:1].CGColor, 32 | (__bridge id)[UIColor colorWithRed:29.0 / 255.0 green:156.0 / 255.0 blue:215.0 / 255.0 alpha:1].CGColor, 33 | (__bridge id)[UIColor colorWithRed:0.0 / 255.0 green:50.0 / 255.0 blue:126.0 / 255.0 alpha:1].CGColor]; 34 | //渐变层的相对位置,起始点为0,终止点为1,中间点为 (point-startpoint)/(endpoint-startpoint) 35 | layer.locations = @[@0,@.5,@1]; 36 | //渐变方向 37 | layer.startPoint = CGPointMake(0, 1); 38 | layer.endPoint = CGPointMake(1, 1); 39 | [self.view.layer addSublayer:layer]; 40 | } 41 | 42 | - (void)didReceiveMemoryWarning { 43 | [super didReceiveMemoryWarning]; 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | /* 48 | #pragma mark - Navigation 49 | 50 | // In a storyboard-based application, you will often want to do a little preparation before navigation 51 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 52 | // Get the new view controller using [segue destinationViewController]. 53 | // Pass the selected object to the new view controller. 54 | } 55 | */ 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawImageView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawImageView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawImageView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawImageView.h" 10 | 11 | @implementation DrawImageView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | 19 | //1.获取当前的上下文 20 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 21 | //2.加载图片 22 | //这里顺便咯嗦一句:使用imageNamed加载图片是会有缓存的 23 | //我们这里只需要加载一次就够了,不需要多次加载,所以不应该保存这个缓存 24 | // UIImage * image = [UIImage imageNamed:@"222"]; //所以可以换一种方式去加载 25 | UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"222.png" ofType:nil]]; 26 | 27 | 28 | // //绘制的大小位置 29 | // [image drawInRect:rect]; 30 | 31 | 32 | // //从某个点开始绘制 33 | // [image drawAtPoint:CGPointMake(0, 0)]; 34 | 35 | 36 | //绘制一个多大的图片,并且设置他的混合模式以及透明度 37 | //Rect:大小位置 38 | //blendModel:混合模式 39 | //alpha:透明度 40 | [image drawInRect:rect blendMode:kCGBlendModeNormal alpha:1]; 41 | 42 | 43 | //从某一点开始绘制图片,并设置混合模式以及透明度 44 | //point:开始位置 45 | //blendModel:混合模式 46 | //alpha:透明度 47 | // [image drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:1]; 48 | 49 | //添加到上下文 50 | CGContextFillPath(contextRef); 51 | } 52 | 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawImageViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawImageViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawImageViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawImageViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawImageViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawImageViewcontroller.h" 10 | #import "DrawImageView.h" 11 | @interface DrawImageViewcontroller () 12 | 13 | @end 14 | 15 | @implementation DrawImageViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | DrawImageView * image = [[DrawImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 21 | image.backgroundColor = [UIColor grayColor]; 22 | [self.view addSubview:image]; 23 | } 24 | 25 | - (void)didReceiveMemoryWarning { 26 | [super didReceiveMemoryWarning]; 27 | // Dispose of any resources that can be recreated. 28 | } 29 | 30 | /* 31 | #pragma mark - Navigation 32 | 33 | // In a storyboard-based application, you will often want to do a little preparation before navigation 34 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 35 | // Get the new view controller using [segue destinationViewController]. 36 | // Pass the selected object to the new view controller. 37 | } 38 | */ 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineColorView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineColorView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawLineColorView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineColorView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineColorView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawLineColorView.h" 10 | 11 | @implementation DrawLineColorView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | 19 | [[self bezierPathWithPoint:CGPointMake(10, 10) endPoint:CGPointMake(10, 180) lineColor:[UIColor purpleColor] lineWidth:6] stroke]; 20 | [[self bezierPathWithPoint:CGPointMake(50, 10) endPoint:CGPointMake(50, 180) lineColor:[UIColor greenColor] lineWidth:6] stroke]; 21 | [[self bezierPathWithPoint:CGPointMake(90, 10) endPoint:CGPointMake(90, 180) lineColor:[UIColor orangeColor] lineWidth:6] stroke]; 22 | 23 | } 24 | 25 | - (UIBezierPath *)bezierPathWithPoint:(CGPoint)startPoint endPoint:(CGPoint) endPoint lineColor:(UIColor*)lineColor lineWidth:(CGFloat)lineWidth{ 26 | UIBezierPath * path = [UIBezierPath bezierPath]; 27 | [lineColor setStroke]; 28 | path.lineWidth = lineWidth; 29 | [path moveToPoint:startPoint]; 30 | [path addLineToPoint:endPoint]; 31 | 32 | return path; 33 | } 34 | 35 | - (void)oneWay{ 36 | //1 获取上下文 37 | //分别设置线段的颜色 38 | CGContextRef purple = UIGraphicsGetCurrentContext(); 39 | [[UIColor purpleColor]setStroke]; 40 | CGContextSaveGState(purple); 41 | 42 | CGContextRef orange = UIGraphicsGetCurrentContext(); 43 | [[UIColor orangeColor]setStroke]; 44 | CGContextSaveGState(orange); 45 | 46 | CGContextRef green = UIGraphicsGetCurrentContext(); 47 | [[UIColor greenColor]setStroke]; 48 | CGContextSaveGState(green); 49 | 50 | 51 | UIBezierPath * path = [UIBezierPath bezierPath]; 52 | //设置线宽 53 | path.lineWidth = 5; 54 | 55 | //把紫色的上下文从栈中取出来 56 | CGContextRestoreGState(purple); 57 | //第一条线 58 | [[UIColor purpleColor]setStroke]; 59 | [path moveToPoint:CGPointMake(10, 10)]; 60 | [path addLineToPoint:CGPointMake(10, 100)]; 61 | [path stroke]; 62 | 63 | 64 | //把紫色的上下文从栈中取出来 65 | CGContextRestoreGState(orange); 66 | path = [UIBezierPath bezierPath]; 67 | //设置线宽 68 | path.lineWidth = 9; 69 | //第二条线 70 | [[UIColor orangeColor]setStroke]; 71 | [path moveToPoint:CGPointMake(30, 10)]; 72 | [path addLineToPoint:CGPointMake(30, 100)]; 73 | [path stroke]; 74 | 75 | //把紫色的上下文从栈中取出来 76 | CGContextRestoreGState(green); 77 | path = [UIBezierPath bezierPath]; 78 | //设置线宽 79 | path.lineWidth = 3; 80 | //第三条线 81 | [[UIColor greenColor]setStroke]; 82 | [path moveToPoint:CGPointMake(50, 10)]; 83 | [path addLineToPoint:CGPointMake(50, 100)]; 84 | [path stroke]; 85 | 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineColorViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineColorViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawLineColorViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineColorViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineColorViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawLineColorViewcontroller.h" 10 | #import "DrawLineColorView.h" 11 | @interface DrawLineColorViewcontroller () 12 | 13 | @end 14 | 15 | @implementation DrawLineColorViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | DrawLineColorView * lineColor = [[DrawLineColorView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | lineColor.backgroundColor = [UIColor grayColor]; 23 | [self.view addSubview:lineColor]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | /* 32 | #pragma mark - Navigation 33 | 34 | // In a storyboard-based application, you will often want to do a little preparation before navigation 35 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 36 | // Get the new view controller using [segue destinationViewController]. 37 | // Pass the selected object to the new view controller. 38 | } 39 | */ 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawLineView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawLineView.h" 10 | 11 | @implementation DrawLineView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | NSLog(@"%s",__func__); 19 | //1.获取上下文 20 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 21 | //2.描述路径 22 | UIBezierPath * path = [UIBezierPath bezierPath]; 23 | //起点 24 | [path moveToPoint:CGPointMake(10, 10)]; 25 | //终点 26 | [path addLineToPoint:CGPointMake(100, 100)]; 27 | //设置颜色 28 | [[UIColor whiteColor]setStroke]; 29 | //3.添加路径 30 | CGContextAddPath(contextRef, path.CGPath); 31 | //显示路径 32 | CGContextStrokePath(contextRef); 33 | } 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawLineViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawLineViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawLineViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawLineViewcontroller.h" 10 | #import "DrawLineView.h" 11 | @interface DrawLineViewcontroller () 12 | 13 | 14 | @end 15 | 16 | @implementation DrawLineViewcontroller 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | NSLog(@"%s",__func__); 21 | self.view.backgroundColor = [UIColor whiteColor]; 22 | DrawLineView * line = [[DrawLineView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 23 | line.backgroundColor = [UIColor grayColor]; 24 | [self.view addSubview:line]; 25 | } 26 | 27 | - (void)viewWillAppear:(BOOL)animated{ 28 | [super viewWillAppear:animated]; 29 | NSLog(@"%s",__func__); 30 | } 31 | 32 | - (void)viewDidAppear:(BOOL)animated{ 33 | [super viewDidAppear:animated]; 34 | NSLog(@"%s",__func__); 35 | } 36 | 37 | - (void)loadView{ 38 | [super loadView]; 39 | NSLog(@"%s",__func__); 40 | } 41 | 42 | - (void)didReceiveMemoryWarning { 43 | [super didReceiveMemoryWarning]; 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | /* 48 | #pragma mark - Navigation 49 | 50 | // In a storyboard-based application, you will often want to do a little preparation before navigation 51 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 52 | // Get the new view controller using [segue destinationViewController]. 53 | // Pass the selected object to the new view controller. 54 | } 55 | */ 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawRectView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawRectView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawRectView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawRectView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawRectView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawRectView.h" 10 | 11 | @implementation DrawRectView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | 19 | //1.获取上下文 20 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 21 | //2.描述路径 22 | UIBezierPath * path = [UIBezierPath bezierPathWithRect:CGRectMake(10, 10, 100, 100)]; 23 | //设置颜色 24 | [[UIColor greenColor]set]; 25 | //3.添加路径 26 | CGContextAddPath(contextRef, path.CGPath); 27 | //显示路径 28 | CGContextFillPath(contextRef); 29 | 30 | } 31 | 32 | 33 | - (void)drawRectWayOne{ 34 | //1.获取上下文 35 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 36 | //2.描述路径 37 | UIBezierPath * path = [UIBezierPath bezierPath]; 38 | //起点 39 | [path moveToPoint:CGPointMake(10, 10)]; 40 | //第二个点 41 | [path addLineToPoint:CGPointMake(100, 10)]; 42 | //第三个点 43 | [path addLineToPoint:CGPointMake(100, 100)]; 44 | //第四个点 45 | [path addLineToPoint:CGPointMake(10, 100)]; 46 | //闭合路径 也等于 [path addLineToPoint:CGPointMake(10, 10)]; 47 | [path closePath]; 48 | //设置颜色 49 | [[UIColor greenColor]setStroke]; 50 | //3.添加路径 51 | CGContextAddPath(contextRef, path.CGPath); 52 | //显示路径 53 | CGContextStrokePath(contextRef); 54 | 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawRectViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawRectViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawRectViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawRectViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawRectViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawRectViewcontroller.h" 10 | #import "DrawRectView.h" 11 | @interface DrawRectViewcontroller () 12 | 13 | @end 14 | 15 | @implementation DrawRectViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | DrawRectView * rect = [[DrawRectView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 21 | rect.backgroundColor = [UIColor grayColor]; 22 | [self.view addSubview:rect]; 23 | } 24 | 25 | - (void)didReceiveMemoryWarning { 26 | [super didReceiveMemoryWarning]; 27 | // Dispose of any resources that can be recreated. 28 | } 29 | 30 | /* 31 | #pragma mark - Navigation 32 | 33 | // In a storyboard-based application, you will often want to do a little preparation before navigation 34 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 35 | // Get the new view controller using [segue destinationViewController]. 36 | // Pass the selected object to the new view controller. 37 | } 38 | */ 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawTextViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawTextViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawTextViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawTextViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawTextViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawTextViewcontroller.h" 10 | #import "DrawTexttView.h" 11 | @interface DrawTextViewcontroller () 12 | 13 | @end 14 | 15 | @implementation DrawTextViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | DrawTexttView * text = [[DrawTexttView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | text.backgroundColor = [UIColor grayColor]; 23 | [self.view addSubview:text]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | /* 32 | #pragma mark - Navigation 33 | 34 | // In a storyboard-based application, you will often want to do a little preparation before navigation 35 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 36 | // Get the new view controller using [segue destinationViewController]. 37 | // Pass the selected object to the new view controller. 38 | } 39 | */ 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawTexttView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DrawTexttView.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DrawTexttView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/DrawTexttView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DrawTexttView.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "DrawTexttView.h" 10 | 11 | @implementation DrawTexttView 12 | 13 | 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | 19 | //1.获取当前上下文 20 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 21 | //2.创建文字 22 | NSString * str = @"纸巾艺术"; 23 | //设置字体样式 24 | NSMutableDictionary * dict = [NSMutableDictionary dictionary]; 25 | //NSFontAttributeName:字体大小 26 | dict[NSFontAttributeName] = [UIFont systemFontOfSize:25]; 27 | //字体前景色 28 | dict[NSForegroundColorAttributeName] = [UIColor blueColor]; 29 | //字体背景色 30 | dict[NSBackgroundColorAttributeName] = [UIColor redColor]; 31 | //字体阴影 32 | NSShadow * shadow = [[NSShadow alloc]init]; 33 | //阴影偏移量 34 | shadow.shadowOffset = CGSizeMake(2, 2); 35 | //阴影颜色 36 | shadow.shadowColor = [UIColor greenColor]; 37 | //高斯模糊 38 | shadow.shadowBlurRadius = 5; 39 | dict[NSShadowAttributeName] = shadow; 40 | //字体间距 41 | dict[NSKernAttributeName] = @10; 42 | //绘制到上下文 43 | //从某一点开始绘制 默认 0 0点 44 | // [str drawAtPoint:CGPointMake(100, 100) withAttributes:nil]; 45 | //绘制区域设置 46 | [str drawInRect:rect withAttributes:dict]; 47 | //添加到上下文 48 | CGContextStrokePath(contextRef); 49 | } 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageAddWaterImageViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageAddWaterImageViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageAddWaterImageViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageAddWaterImageViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageAddWaterImageViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageAddWaterImageViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageAddWaterImageViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageAddWaterImageViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | imageView.image = [UIImage pq_WaterImageWithImage:[UIImage imageNamed:@"222"] waterImage:[UIImage imageNamed:@"222"] waterImageRect:CGRectMake(30, 30, 50, 50)]; 23 | [self.view addSubview:imageView]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | /* 32 | #pragma mark - Navigation 33 | 34 | // In a storyboard-based application, you will often want to do a little preparation before navigation 35 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 36 | // Get the new view controller using [segue destinationViewController]. 37 | // Pass the selected object to the new view controller. 38 | } 39 | */ 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageAddWaterTextViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageAddWaterTextViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageAddWaterTextViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageAddWaterTextViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageAddWaterTextViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageAddWaterTextViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageAddWaterTextViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageAddWaterTextViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | 23 | //设置字体样式 24 | NSMutableDictionary * dict = [NSMutableDictionary dictionary]; 25 | //NSFontAttributeName:字体大小 26 | dict[NSFontAttributeName] = [UIFont systemFontOfSize:25]; 27 | //字体前景色 28 | dict[NSForegroundColorAttributeName] = [UIColor blueColor]; 29 | //字体背景色 30 | dict[NSBackgroundColorAttributeName] = [UIColor redColor]; 31 | //字体阴影 32 | NSShadow * shadow = [[NSShadow alloc]init]; 33 | //阴影偏移量 34 | shadow.shadowOffset = CGSizeMake(3, 5); 35 | //阴影颜色 36 | shadow.shadowColor = [UIColor greenColor]; 37 | //高斯模糊 38 | shadow.shadowBlurRadius = 5; 39 | dict[NSShadowAttributeName] = shadow; 40 | //字体间距 41 | dict[NSKernAttributeName] = @10; 42 | 43 | imageView.image = [UIImage pq_WaterImageWithImage:[UIImage imageNamed:@"222"] text:@"纸巾艺术" textPoint:CGPointMake(30, 30) attributedString:dict]; 44 | [self.view addSubview:imageView]; 45 | } 46 | 47 | - (void)didReceiveMemoryWarning { 48 | [super didReceiveMemoryWarning]; 49 | // Dispose of any resources that can be recreated. 50 | } 51 | 52 | /* 53 | #pragma mark - Navigation 54 | 55 | // In a storyboard-based application, you will often want to do a little preparation before navigation 56 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 57 | // Get the new view controller using [segue destinationViewController]. 58 | // Pass the selected object to the new view controller. 59 | } 60 | */ 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipCircleAndBorderViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipCircleAndBorderViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageClipCircleAndBorderViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipCircleAndBorderViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipCircleAndBorderViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageClipCircleAndBorderViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageClipCircleAndBorderViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageClipCircleAndBorderViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | UIImage * image = [UIImage imageNamed:@"222"]; 23 | imageView.image = [UIImage pq_ClipCircleImageWithImage:image circleRect:CGRectMake(0, 0, image.size.width, image.size.height) borderWidth:10 borderColor:[UIColor greenColor]]; 24 | [self.view addSubview:imageView]; 25 | } 26 | 27 | - (void)didReceiveMemoryWarning { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | /* 33 | #pragma mark - Navigation 34 | 35 | // In a storyboard-based application, you will often want to do a little preparation before navigation 36 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 37 | // Get the new view controller using [segue destinationViewController]. 38 | // Pass the selected object to the new view controller. 39 | } 40 | */ 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipCircleViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipCircleViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageClipCircleViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipCircleViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipCircleViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageClipCircleViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageClipCircleViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageClipCircleViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | UIImage * image = [UIImage imageNamed:@"222"]; 23 | imageView.image = [UIImage pq_ClipCircleImageWithImage:image circleRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 24 | [self.view addSubview:imageView]; 25 | } 26 | 27 | - (void)didReceiveMemoryWarning { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | /* 33 | #pragma mark - Navigation 34 | 35 | // In a storyboard-based application, you will often want to do a little preparation before navigation 36 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 37 | // Get the new view controller using [segue destinationViewController]. 38 | // Pass the selected object to the new view controller. 39 | } 40 | */ 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipRectImageViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipRectImageViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageClipRectImageViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageClipRectImageViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageClipRectImageViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageClipRectImageViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | #import "UIView+pgqViewExtension.h" 12 | #import "PQWipeView.h" 13 | @interface ImageClipRectImageViewcontroller () 14 | 15 | @property (nonatomic,strong) PQWipeView * wipeView; 16 | @property (nonatomic,strong) UIImageView * imgView; 17 | 18 | @end 19 | 20 | @implementation ImageClipRectImageViewcontroller{ 21 | UIImage *_image; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | self.automaticallyAdjustsScrollViewInsets = YES; 27 | self.view.backgroundColor = [UIColor whiteColor]; 28 | //添加一个右按钮 29 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"确定裁剪" style:UIBarButtonItemStylePlain target:self action:@selector(cutFinish)]; 30 | 31 | _image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"back.jpg" ofType:nil]]; 32 | //添加一个背景图片 33 | UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 64, self.view.width, self.view.height)]; 34 | imgView.image = _image; 35 | [self.view addSubview:imgView]; 36 | self.imgView = imgView; 37 | self.imgView.userInteractionEnabled = YES; 38 | 39 | _wipeView = [[[NSBundle mainBundle]loadNibNamed:@"PQWipeView" owner:self options:nil] firstObject]; 40 | [self.imgView addSubview:_wipeView]; 41 | } 42 | 43 | - (void)cutFinish{ 44 | 45 | [UIImage pq_cutScreenWithView:self.imgView cutFrame:self.wipeView.frame successBlock:^(UIImage * _Nullable image, NSData * _Nullable imagedata) { 46 | if (image) { 47 | NSLog(@"截取成功"); 48 | NSString * path = [NSString stringWithFormat:@"%@/Documents/cutSome.jpg",NSHomeDirectory()]; 49 | 50 | if( [imagedata writeToFile:path atomically:YES]){ 51 | NSLog(@"保存成功%@",path); 52 | } 53 | 54 | self.imgView.hidden = YES; 55 | 56 | UIImageView * imagev = [[UIImageView alloc]initWithImage:image]; 57 | imagev.x = 0; 58 | imagev.y = 64; 59 | [self.view addSubview:imagev]; 60 | } 61 | }]; 62 | 63 | } 64 | 65 | - (void)didReceiveMemoryWarning { 66 | [super didReceiveMemoryWarning]; 67 | // Dispose of any resources that can be recreated. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageContextViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageContextViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageContextViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageContextViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageContextViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageContextViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageContextViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageContextViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)]; 22 | imageView.image = [UIImage pq_drawImageWithImageNamed:@"222.png"]; 23 | [self.view addSubview:imageView]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageCutViewViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCutViewViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageCutViewViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageCutViewViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCutViewViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageCutViewViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageCutViewViewcontroller () 12 | 13 | @end 14 | 15 | @implementation ImageCutViewViewcontroller 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | 22 | UIImage * image = [UIImage imageNamed:@"222"]; 23 | 24 | //添加一个些东西 25 | UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 80, 100, 20)]; 26 | label.backgroundColor = [UIColor orangeColor]; 27 | [self.view addSubview:label]; 28 | 29 | UIView * view = [[UIView alloc]initWithFrame:CGRectMake(100, 150, 100, 200)]; 30 | view.backgroundColor = [UIColor colorWithPatternImage:image]; 31 | [self.view addSubview:view]; 32 | 33 | UIButton * button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 34 | [self.view addSubview:button]; 35 | button.frame = CGRectMake(0, 400, 50, 40); 36 | 37 | self.title = @"点击空白区,进行截屏"; 38 | 39 | } 40 | 41 | - (void)didReceiveMemoryWarning { 42 | [super didReceiveMemoryWarning]; 43 | // Dispose of any resources that can be recreated. 44 | } 45 | 46 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 47 | [UIImage pq_cutScreenWithView:self.view successBlock:^(UIImage * _Nullable image, NSData * _Nullable imagedata) { 48 | if (image) { 49 | NSLog(@"截取成功"); 50 | NSString * path = [NSString stringWithFormat:@"%@/Documents/cut.jpg",NSHomeDirectory()]; 51 | 52 | if( [imagedata writeToFile:path atomically:YES]){ 53 | NSLog(@"保存成功%@",path); 54 | } 55 | 56 | } 57 | 58 | 59 | }]; 60 | } 61 | 62 | /* 63 | #pragma mark - Navigation 64 | 65 | // In a storyboard-based application, you will often want to do a little preparation before navigation 66 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 67 | // Get the new view controller using [segue destinationViewController]. 68 | // Pass the selected object to the new view controller. 69 | } 70 | */ 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageWipeViewcontroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageWipeViewcontroller.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageWipeViewcontroller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ImageWipeViewcontroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageWipeViewcontroller.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ImageWipeViewcontroller.h" 10 | #import "UIImage+PQImage.h" 11 | @interface ImageWipeViewcontroller () 12 | 13 | @property (nonatomic,weak) UIImageView * wipeImageV; 14 | 15 | @end 16 | 17 | @implementation ImageWipeViewcontroller{ 18 | CGPoint _statrPoint; 19 | } 20 | 21 | - (UIImageView *)wipeImageV{ 22 | if (!_wipeImageV) { 23 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; 24 | UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fore.jpg" ofType:nil]]; 25 | imageView.image = image; 26 | [self.view addSubview:imageView]; 27 | _wipeImageV = imageView; 28 | } 29 | return _wipeImageV; 30 | } 31 | 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | 35 | self.automaticallyAdjustsScrollViewInsets = NO; 36 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:self.view.bounds]; 37 | imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"back.jpg" ofType:nil]]; 38 | [self.view addSubview:imageView]; 39 | 40 | UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(wipePanGestureEvent:)]; 41 | self.wipeImageV.userInteractionEnabled = YES; 42 | [self.wipeImageV addGestureRecognizer:pan]; 43 | } 44 | 45 | - (void)didReceiveMemoryWarning { 46 | [super didReceiveMemoryWarning]; 47 | // Dispose of any resources that can be recreated. 48 | } 49 | 50 | 51 | - (void)wipePanGestureEvent:(UIPanGestureRecognizer * )pan{ 52 | // //计算位置 53 | // CGPoint nowPoint = [pan locationInView:self.wipeImageV]; 54 | // CGFloat offsetX = nowPoint.x - 10; 55 | // CGFloat offsetY = nowPoint.y - 10; 56 | // CGRect clipRect = CGRectMake(offsetX, offsetY, 20, 20); 57 | // 58 | // //开启上下文 59 | // UIGraphicsBeginImageContextWithOptions(self.wipeImageV.bounds.size, NO, 1); 60 | // //获取当前的上下文 61 | // CGContextRef ctx = UIGraphicsGetCurrentContext(); 62 | // 63 | // //把图片绘制上去 64 | // [self.wipeImageV.layer renderInContext:ctx]; 65 | // 66 | // //把这一块设置为透明 67 | // CGContextClearRect(ctx, clipRect); 68 | // 69 | // //获取新的图片 70 | // UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 71 | // 72 | // //关闭上下文 73 | // UIGraphicsEndImageContext(); 74 | // 75 | // //重新赋值图片 76 | // self.wipeImageV.image = newImage; 77 | 78 | //封装后如下 79 | self.wipeImageV.image = [self.wipeImageV.image pq_wipeImageWithView:self.wipeImageV currentPoint:[pan locationInView:self.wipeImageV] size:CGSizeMake(40, 40)]; 80 | 81 | } 82 | 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/LineView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineView.h 3 | // DrawLineDemo 4 | // 5 | // Created by pgq on 2017/12/11. 6 | // Copyright © 2017年 pgq. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LineView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/LineView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LineView.m 3 | // DrawLineDemo 4 | // 5 | // Created by pgq on 2017/12/11. 6 | // Copyright © 2017年 pgq. All rights reserved. 7 | // 8 | 9 | #import "LineView.h" 10 | 11 | @implementation LineView 12 | - (instancetype)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if (self) { 16 | self.backgroundColor = [UIColor whiteColor]; 17 | } 18 | return self; 19 | } 20 | 21 | 22 | - (void)drawRect:(CGRect)rect { 23 | 24 | //画线 25 | [self drawLine]; 26 | 27 | //画一个渐变色的线 28 | [self drawLineWithStartColor:[UIColor redColor] endColor:[UIColor greenColor]]; 29 | } 30 | 31 | - (void)drawLineWithStartColor:(UIColor *)startColor endColor:(UIColor *)endColor{ 32 | //1、获取上下文 33 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 34 | 35 | //3、创建一个颜色空间 36 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 37 | //4、设置颜色的location 38 | CGFloat locations[] = { 0.0, 1.0 }; 39 | //5、创建一个颜色数组,由于NSArray里面只能存对象,所以需要桥接 40 | NSArray *colors = @[(__bridge id)startColor.CGColor,(__bridge id)endColor.CGColor]; 41 | 42 | CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations); 43 | //释放 44 | CFRelease(colorSpace); 45 | 46 | //保存一份当前上下文,压栈 47 | CGContextSaveGState(ctx); 48 | 49 | //绘制一个矩形,矩形足够小,也可以是一条线 50 | CGFloat width = self.frame.size.width; 51 | CGContextMoveToPoint(ctx, 0, 120); 52 | CGContextAddLineToPoint(ctx, width, 120); 53 | CGContextAddLineToPoint(ctx, width, 123); 54 | CGContextAddLineToPoint(ctx, 0, 123); 55 | //裁剪 56 | CGContextEOClip(ctx); 57 | 58 | //绘制渐变 59 | CGContextDrawLinearGradient(ctx, gradient, CGPointMake(0, 100), CGPointMake(self.frame.size.width, 100), kCGGradientDrawsBeforeStartLocation); 60 | 61 | //恢复一份当前的上下文,出栈 62 | CGContextRestoreGState(ctx); 63 | 64 | //释放内存 65 | CGColorSpaceRelease(colorSpace); 66 | CGGradientRelease(gradient); 67 | } 68 | 69 | - (void)drawLine{ 70 | //1、获取上下文 71 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 72 | 73 | //2画一条直线的需要知道的就是两个点,也就是起点和终点 74 | //2.1、选择一个点最为画线的起点 75 | CGContextMoveToPoint(ctx, 0, 100); 76 | //2.2、设置线的终点 77 | CGContextAddLineToPoint(ctx, 300, 100); 78 | 79 | CGContextSetLineWidth(ctx, 3); 80 | 81 | //3、填充路径 填充路径的方法有两个 一个是 stroke(描边) 一个 fill(填充) 82 | CGContextStrokePath(ctx);// 类似于描边 83 | 84 | //4、释放内存 85 | CGContextRelease(ctx); 86 | } 87 | 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQTBDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // PQTBDataSource.h 3 | // PQSeparationCode 4 | // 5 | // Created by codepgq on 16/8/6. 6 | // Copyright © 2016年 PQ. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | 14 | @interface PQTBDataSource : NSObject 15 | //传入之后不允许用户在外面随意更改数据 16 | @property (nonatomic,strong,readonly) NSMutableArray * _Nullable valuesArray; 17 | 18 | + (nonnull instancetype)dataSourceWith:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellConfigBlock:(nullable void(^)( id _Nullable cell,id _Nullable item))block; 19 | - (nonnull instancetype)initWithDataSource:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellConfigBlock:(nullable void(^)(id _Nullable cell,id _Nullable item))block; 20 | 21 | //提供方法更新,删除,获取 22 | - (void)pq_insertValueWithItem:(NSInteger)item value:(id _Nullable)value; 23 | - (void)pq_deleteValueWithItem:(NSInteger)item; 24 | - (id _Nullable)pq_valueWithItem:(NSInteger)item; 25 | - (void)pq_updateWithArray:(nullable NSArray *)array; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQTBDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // PQTBDataSource.m 3 | // PQSeparationCode 4 | // 5 | // Created by codepgq on 16/8/6. 6 | // Copyright © 2016年 PQ. All rights reserved. 7 | // 8 | 9 | #import "PQTBDataSource.h" 10 | #import "SectionModel.h" 11 | typedef void(^CellConfigBlock)(id _Nullable cell, id _Nullable item); 12 | @interface PQTBDataSource () 13 | //传入之后不允许用户在外面随意更改数据 14 | @property (nonatomic,strong,readwrite) NSMutableArray * _Nullable valuesArray; 15 | @property (nonatomic,copy) NSString * identifier; 16 | @property (nonatomic,copy) CellConfigBlock cellConfigBlock; 17 | @end 18 | 19 | @implementation PQTBDataSource 20 | 21 | 22 | + (nonnull instancetype)dataSourceWith:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellConfigBlock:(nullable void(^)( id _Nullable cell,id _Nullable item))block{ 23 | return [[self alloc]initWithDataSource:values identifier:identifier cellConfigBlock:block]; 24 | } 25 | - (nonnull instancetype)initWithDataSource:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellConfigBlock:(nullable void(^)(id _Nullable cell,id _Nullable item))block 26 | { 27 | self = [super init]; 28 | if (self) { 29 | self.identifier = identifier ; 30 | self.valuesArray = [NSMutableArray arrayWithArray:values]; 31 | self.cellConfigBlock = [block copy]; 32 | } 33 | return self; 34 | } 35 | 36 | //提供方法更新,删除,获取 37 | - (void)pq_insertValueWithItem:(NSInteger)item value:(id _Nullable)value{ 38 | if ([self canEditArray:item]) { 39 | [self.valuesArray insertObject:value atIndex:item]; 40 | } 41 | } 42 | - (void)pq_deleteValueWithItem:(NSInteger)item{ 43 | if ([self canEditArray:item]) { 44 | [self.valuesArray removeObjectAtIndex:item]; 45 | } 46 | } 47 | - (id _Nullable)pq_valueWithItem:(NSInteger)item{ 48 | if ([self canEditArray:item]) { 49 | return self.valuesArray[item]; 50 | } 51 | return nil; 52 | } 53 | 54 | - (BOOL)canEditArray:(NSInteger)item{ 55 | if (item < self.valuesArray.count && item >= 0) { 56 | return YES; 57 | } 58 | return NO; 59 | } 60 | 61 | - (void)pq_updateWithArray:(NSArray *)array{ 62 | self.valuesArray = nil; 63 | self.valuesArray = [NSMutableArray arrayWithArray:array]; 64 | } 65 | 66 | - (id _Nullable )itemWithIndexPath:(NSIndexPath *)indexPath{ 67 | return [self.valuesArray[indexPath.section] items][indexPath.row]; 68 | } 69 | 70 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 71 | return self.valuesArray.count; 72 | } 73 | 74 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 75 | SectionModel * model = self.valuesArray[section]; 76 | return model.items.count; 77 | } 78 | 79 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 80 | id cell = [tableView dequeueReusableCellWithIdentifier:self.identifier forIndexPath:indexPath]; 81 | id item = [self itemWithIndexPath:indexPath]; 82 | self.cellConfigBlock(cell,item); 83 | return cell; 84 | } 85 | 86 | 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQTBDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PQTBDelegate.h 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface PQTBDelegate : NSObject 12 | 13 | //传入之后不允许用户在外面随意更改数据 14 | @property (nonatomic,strong,readonly) NSMutableArray * _Nullable valuesArray; 15 | @property (nonatomic,assign) CGFloat headerH; 16 | 17 | + (nonnull instancetype)delegateWith:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellSelectedBlock:(nullable void(^)( id _Nullable cell,id _Nullable item))block; 18 | - (nonnull instancetype)initWithdelegate:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellSelectedBlock:(nullable void(^)(id _Nullable cell,id _Nullable item))block; 19 | @end 20 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQTBDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PQTBDelegate.m 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "PQTBDelegate.h" 10 | #import "UIView+pgqViewExtension.h" 11 | #import "SectionModel.h" 12 | typedef void(^CellSelectedBlock)(id _Nullable cell, id _Nullable item); 13 | 14 | @interface PQTBDelegate () 15 | //传入之后不允许用户在外面随意更改数据 16 | @property (nonatomic,strong,readwrite) NSMutableArray * _Nullable valuesArray; 17 | @property (nonatomic,copy) CellSelectedBlock cellSelectedBlock; 18 | @property (nonatomic,copy) NSString *identifier; 19 | @end 20 | 21 | @implementation PQTBDelegate 22 | 23 | + (nonnull instancetype)delegateWith:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellSelectedBlock:(nullable void(^)( id _Nullable cell,id _Nullable item))block{ 24 | return [[self alloc]initWithdelegate:values identifier:identifier cellSelectedBlock:block]; 25 | } 26 | - (nonnull instancetype)initWithdelegate:(nullable NSArray *)values identifier:(nullable NSString *)identifier cellSelectedBlock:(nullable void(^)(id _Nullable cell,id _Nullable item))block 27 | { 28 | self = [super init]; 29 | if (self) { 30 | self.valuesArray = [NSMutableArray arrayWithArray:values]; 31 | self.cellSelectedBlock = [block copy]; 32 | self.identifier = identifier; 33 | self.headerH = 30; 34 | } 35 | return self; 36 | } 37 | 38 | - (id _Nullable )itemWithIndexPath:(NSIndexPath *)indexPath{ 39 | return [self.valuesArray[indexPath.section] items][indexPath.row]; 40 | } 41 | 42 | 43 | - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 44 | UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 60, 30)]; 45 | UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 200, 30)]; 46 | label.contentMode = UIViewContentModeCenter; 47 | SectionModel * sec =self.valuesArray[section]; 48 | label.text = sec.section; 49 | [view addSubview:label]; 50 | view.backgroundColor = [UIColor grayColor]; 51 | return view; 52 | } 53 | 54 | 55 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ 56 | return self.headerH; 57 | } 58 | 59 | // Called after the user changes the selection. 60 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 61 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 62 | id cell = [tableView cellForRowAtIndexPath:indexPath]; 63 | id item = [self itemWithIndexPath:indexPath]; 64 | self.cellSelectedBlock(cell,item); 65 | } 66 | 67 | 68 | 69 | 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQWipeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PQWipeView.h 3 | // PQDrawTest 4 | // 5 | // Created by codepgq on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PQWipeView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQWipeView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PQWipeView.m 3 | // PQDrawTest 4 | // 5 | // Created by codepgq on 16/8/15. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "PQWipeView.h" 10 | #import "UIView+pgqViewExtension.h" 11 | @interface PQWipeView () 12 | 13 | @property (nonatomic,weak) IBOutlet UIButton * sizeBtn; 14 | 15 | @end 16 | 17 | @implementation PQWipeView{ 18 | CGPoint _startP; 19 | CGPoint _sizeStartP; 20 | 21 | CGSize oldSize; 22 | } 23 | 24 | - (void)awakeFromNib{ 25 | self.y = 0; 26 | } 27 | 28 | - (IBAction)sizePan:(UIPanGestureRecognizer *)sender { 29 | 30 | switch (sender.state) { 31 | case UIGestureRecognizerStateBegan: 32 | _sizeStartP = [sender locationInView:self]; 33 | oldSize = self.size; 34 | break; 35 | 36 | case UIGestureRecognizerStateChanged: 37 | { 38 | CGPoint curP = [sender locationInView:self ]; 39 | 40 | CGFloat w = curP.x - _sizeStartP.x; 41 | CGFloat h = curP.y - _sizeStartP.y; 42 | 43 | self.width = oldSize.width + w; 44 | self.height = oldSize.height + h; 45 | 46 | [self ifOut]; 47 | } 48 | break; 49 | 50 | default: 51 | break; 52 | } 53 | } 54 | 55 | 56 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 57 | UITouch * touch = [touches anyObject]; 58 | //得到按下去的点 59 | _startP = [touch locationInView:self]; 60 | } 61 | 62 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 63 | UITouch * touch = [touches anyObject]; 64 | 65 | CGPoint curP = [touch locationInView:self]; 66 | //计算偏移量 67 | CGFloat x = curP.x - _startP.x; 68 | CGFloat y = curP.y - _startP.y; 69 | 70 | //限制范围 不允许超出屏幕 71 | 72 | self.x += x; 73 | if (self.x <=0) { 74 | self.x = 0; 75 | } 76 | self.y += y; 77 | if (self.y <= 0) { 78 | self.y = 0; 79 | } 80 | //范围判断 81 | [self ifOut]; 82 | } 83 | 84 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 85 | 86 | } 87 | 88 | - (void)ifOut{ 89 | if (self.y + self.height >= [UIScreen mainScreen].bounds.size.height-64) { 90 | self.y = [UIScreen mainScreen].bounds.size.height - self.height - 64; 91 | } 92 | 93 | if (self.x + self.width >= [UIScreen mainScreen].bounds.size.width) { 94 | self.x = [UIScreen mainScreen].bounds.size.width - self.width; 95 | } 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/PQWipeView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/SectionModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // SectionModel.h 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SectionModel : NSObject 12 | 13 | @property (nonatomic,copy) NSString * section; 14 | @property (nonatomic,strong) NSArray * items; 15 | 16 | 17 | + (instancetype)sectionWithDict:(NSDictionary *)dict; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/SectionModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // SectionModel.m 3 | // 刘振tableviewdemo 4 | // 5 | // Created by ios on 16/8/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "SectionModel.h" 10 | #import "CellModel.h" 11 | @implementation SectionModel 12 | + (instancetype)sectionWithDict:(NSDictionary *)dict{ 13 | SectionModel * sec = [[self alloc]init]; 14 | 15 | [sec setValuesForKeysWithDictionary:dict]; 16 | 17 | return sec; 18 | } 19 | 20 | - (void)setItems:(NSArray *)items{ 21 | NSMutableArray * mArr = [NSMutableArray array]; 22 | for (id dict in items) { 23 | CellModel * model = [CellModel cellWithDict:dict]; 24 | [mArr addObject:model]; 25 | } 26 | _items = mArr; 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/UIImage+PQImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+PQImage.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (PQImage) 12 | /** 13 | * 传入图片:xx.png xx.jpg 14 | * 15 | * @param name 16 | * 17 | * @return 18 | */ 19 | + (nullable UIImage *)pq_drawImageWithImageNamed:(nullable NSString *)name; 20 | 21 | /** 22 | * 添加图片水印 23 | * 24 | * @param image 25 | * @param waterImage 26 | * @param rect 27 | * 28 | * @return 29 | */ 30 | + (nullable UIImage *)pq_WaterImageWithImage:(nullable UIImage *)image waterImage:(nullable UIImage *)waterImage waterImageRect:(CGRect)rect; 31 | /** 32 | * 添加文字水印 33 | * 34 | * @param image 35 | * @param text 36 | * @param point 37 | * @param attributed 38 | * 39 | * @return 40 | */ 41 | + (nullable UIImage *)pq_WaterImageWithImage:(nullable UIImage *)image text:(nullable NSString *)text textPoint:(CGPoint)point attributedString:(nullable NSDictionary< NSString *, id> *)attributed; 42 | /** 43 | * 裁剪圆形图片 44 | * 45 | * @param image <#image description#> 46 | * @param rect <#rect description#> 47 | * 48 | * @return <#return value description#> 49 | */ 50 | + (nullable UIImage *)pq_ClipCircleImageWithImage:(nullable UIImage *)image circleRect:(CGRect)rect; 51 | /** 52 | * 裁剪圆形图片并设置边框大小和颜色 53 | * 54 | * @param image <#image description#> 55 | * @param rect <#rect description#> 56 | * @param borderW <#borderW description#> 57 | * @param borderColor <#borderColor description#> 58 | * 59 | * @return <#return value description#> 60 | */ 61 | + (nullable UIImage *)pq_ClipCircleImageWithImage:(nullable UIImage *)image circleRect:(CGRect)rect borderWidth:(CGFloat)borderW borderColor:(nullable UIColor *)borderColor; 62 | 63 | /** 64 | * 对View进行截屏 65 | * 66 | * @param view 67 | */ 68 | + (void)pq_cutScreenWithView:(nullable UIView *)view successBlock:(nullable void(^)(UIImage * _Nullable image,NSData * _Nullable imagedata))block; 69 | /** 70 | * 对view的某一部分进行裁剪 71 | * 72 | * @param view <#view description#> 73 | * @param frame <#frame description#> 74 | * @param block <#block description#> 75 | */ 76 | + (void)pq_cutScreenWithView:(nullable UIView *)view cutFrame:(CGRect)frame successBlock:(nullable void(^)(UIImage * _Nullable image,NSData * _Nullable imagedata))block; 77 | 78 | /** 79 | * 传入一个ImageView,添加向下透明区域 80 | * 81 | * @param view <#view description#> 82 | * @param nowPoint <#nowPoint description#> 83 | * @param size <#size description#> 84 | * 85 | * @return <#return value description#> 86 | */ 87 | - (nullable UIImage *)pq_wipeImageWithView:(nullable UIView *)view currentPoint:(CGPoint)nowPoint size:(CGSize)size; 88 | @end 89 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/UIImage+PQImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+PQImage.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "UIImage+PQImage.h" 10 | #import "PQWipeView.h" 11 | @implementation UIImage (PQImage) 12 | 13 | + (UIImage *)pq_drawImageWithImageNamed:(NSString *)name{ 14 | //1.获取图片 15 | UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:nil]]; 16 | //2.开启图形上下文 17 | UIGraphicsBeginImageContext(image.size); 18 | //3.绘制到图形上下文中 19 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 20 | //4.从上下文中获取图片 21 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 22 | //5.关闭图形上下文 23 | UIGraphicsEndImageContext(); 24 | //返回图片 25 | return newImage; 26 | } 27 | 28 | + (UIImage *)pq_WaterImageWithImage:(UIImage *)image waterImage:(UIImage *)waterImage waterImageRect:(CGRect)rect{ 29 | 30 | //1.获取图片 31 | 32 | //2.开启上下文 33 | UIGraphicsBeginImageContextWithOptions(image.size, NO, 0); 34 | //3.绘制背景图片 35 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 36 | //绘制水印图片到当前上下文 37 | [waterImage drawInRect:rect]; 38 | //4.从上下文中获取新图片 39 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 40 | //5.关闭图形上下文 41 | UIGraphicsEndImageContext(); 42 | //返回图片 43 | return newImage; 44 | } 45 | 46 | + (UIImage *)pq_WaterImageWithImage:(UIImage *)image text:(NSString *)text textPoint:(CGPoint)point attributedString:(NSDictionary * )attributed{ 47 | 48 | //1.开启上下文 49 | UIGraphicsBeginImageContextWithOptions(image.size, NO, 0); 50 | //2.绘制图片 51 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 52 | //添加水印文字 53 | [text drawAtPoint:point withAttributes:attributed]; 54 | //3.从上下文中获取新图片 55 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 56 | //4.关闭图形上下文 57 | UIGraphicsEndImageContext(); 58 | //返回图片 59 | return newImage; 60 | 61 | } 62 | 63 | 64 | + (nullable UIImage *)pq_ClipCircleImageWithImage:(nullable UIImage *)image circleRect:(CGRect)rect{ 65 | 66 | //1、开启上下文 67 | UIGraphicsBeginImageContextWithOptions(image.size, NO, 0); 68 | 69 | //2、设置裁剪区域 70 | UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:rect]; 71 | [path addClip]; 72 | 73 | //3、绘制图片 74 | [image drawAtPoint:CGPointZero]; 75 | 76 | //4、获取新图片 77 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 78 | 79 | //5、关闭上下文 80 | UIGraphicsEndImageContext(); 81 | 82 | //6、返回新图片 83 | return newImage; 84 | } 85 | 86 | + (nullable UIImage *)pq_ClipCircleImageWithImage:(nullable UIImage *)image circleRect:(CGRect)rect borderWidth:(CGFloat)borderW borderColor:(nullable UIColor *)borderColor{ 87 | //1、开启上下文 88 | UIGraphicsBeginImageContextWithOptions(image.size, NO, 0); 89 | 90 | //2、设置边框 91 | UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:rect]; 92 | [borderColor setFill]; 93 | [path fill]; 94 | 95 | //3、设置裁剪区域 96 | UIBezierPath * clipPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(rect.origin.x + borderW , rect.origin.x + borderW , rect.size.width - borderW * 2, rect.size.height - borderW *2)]; 97 | [clipPath addClip]; 98 | 99 | //3、绘制图片 100 | [image drawAtPoint:CGPointZero]; 101 | 102 | //4、获取新图片 103 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 104 | //5、关闭上下文 105 | UIGraphicsEndImageContext(); 106 | //6、返回新图片 107 | return newImage; 108 | } 109 | 110 | + (void)pq_cutScreenWithView:(nullable UIView *)view successBlock:(nullable void(^)(UIImage * _Nullable image,NSData * _Nullable imagedata))block{ 111 | //1、开启上下文 112 | UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0); 113 | 114 | //2.获取当前上下文 115 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 116 | 117 | //3.截屏 118 | [view.layer renderInContext:ctx]; 119 | 120 | //4、获取新图片 121 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 122 | 123 | //5.转化成为Data 124 | //compressionQuality:表示压缩比 0 - 1的取值范围 125 | NSData * data = UIImageJPEGRepresentation(newImage, 1); 126 | //6、关闭上下文 127 | UIGraphicsEndImageContext(); 128 | 129 | //7.回调 130 | block(newImage,data); 131 | } 132 | 133 | + (void)pq_cutScreenWithView:(nullable UIView *)view cutFrame:(CGRect)frame successBlock:(nullable void(^)(UIImage * _Nullable image,NSData * _Nullable imagedata))block{ 134 | 135 | //先把裁剪区域上面显示的层隐藏掉 136 | for (PQWipeView * wipe in view.subviews) { 137 | [wipe setHidden:YES]; 138 | } 139 | 140 | 141 | // ************************ 进行第一次裁剪 ******************** 142 | 143 | //1.开启上下文 144 | UIGraphicsBeginImageContext(view.frame.size); 145 | //2、获取当前的上下文 146 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 147 | //3、添加裁剪区域 148 | UIBezierPath * path = [UIBezierPath bezierPathWithRect:frame]; 149 | [path addClip]; 150 | //4、渲染 151 | [view.layer renderInContext:ctx]; 152 | //5、从上下文中获取 153 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 154 | //7、关闭上下文 155 | UIGraphicsEndImageContext(); 156 | 157 | //8、进行完第一次裁剪之后,我们就已经拿到了没有半透明层的图片,这个时候可以恢复显示 158 | for (PQWipeView * wipe in view.subviews) { 159 | [wipe setHidden:NO]; 160 | } 161 | 162 | // ************************ 进行第二次裁剪 ******************** 163 | //9、开启上下文,这个时候的大小就是我们最终要显示图片的大小 164 | UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0); 165 | 166 | //10、这里把x y 坐标向左、上移动 167 | [newImage drawAtPoint:CGPointMake(- frame.origin.x, - frame.origin.y)]; 168 | 169 | //11、得到要显示区域的图片 170 | UIImage * fImage = UIGraphicsGetImageFromCurrentImageContext(); 171 | //12、得到data类型 便于保存 172 | NSData * data2 = UIImageJPEGRepresentation(fImage, 1); 173 | //13、关闭上下文 174 | UIGraphicsEndImageContext(); 175 | //14、回调 176 | block(fImage,data2); 177 | } 178 | 179 | - (nullable UIImage *)pq_wipeImageWithView:(nullable UIView *)view currentPoint:(CGPoint)nowPoint size:(CGSize)size{ 180 | //计算位置 181 | CGFloat offsetX = nowPoint.x - size.width * 0.5; 182 | CGFloat offsetY = nowPoint.y - size.height * 0.5; 183 | CGRect clipRect = CGRectMake(offsetX, offsetY, size.width, size.height); 184 | 185 | //开启上下文 186 | UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0); 187 | //获取当前的上下文 188 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 189 | 190 | //把图片绘制上去 191 | [view.layer renderInContext:ctx]; 192 | 193 | //把这一块设置为透明 194 | CGContextClearRect(ctx, clipRect); 195 | 196 | //获取新的图片 197 | UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); 198 | 199 | //关闭上下文 200 | UIGraphicsEndImageContext(); 201 | 202 | //重新赋值图片 203 | return newImage; 204 | } 205 | 206 | @end 207 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/UIView+pgqViewExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+pgqViewExtension.h 3 | // Category 4 | // 5 | // Created by ios on 16/7/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (pgqViewExtension) 12 | @property (nonatomic, assign) CGFloat x; 13 | @property (nonatomic, assign) CGFloat y; 14 | @property (nonatomic, assign) CGFloat centerX; 15 | @property (nonatomic, assign) CGFloat centerY; 16 | @property (nonatomic, assign) CGFloat width; 17 | @property (nonatomic, assign) CGFloat height; 18 | @property (nonatomic, assign) CGSize size; 19 | @property (nonatomic, assign) CGPoint origin; 20 | @end 21 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/UIView+pgqViewExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+pgqViewExtension.m 3 | // Category 4 | // 5 | // Created by ios on 16/7/11. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "UIView+pgqViewExtension.h" 10 | 11 | @implementation UIView (pgqViewExtension) 12 | - (void)setX:(CGFloat)x 13 | { 14 | CGRect frame = self.frame; 15 | frame.origin.x = x; 16 | self.frame = frame; 17 | } 18 | 19 | - (void)setY:(CGFloat)y 20 | { 21 | CGRect frame = self.frame; 22 | frame.origin.y = y; 23 | self.frame = frame; 24 | } 25 | 26 | - (CGFloat)x 27 | { 28 | return self.frame.origin.x; 29 | } 30 | 31 | - (CGFloat)y 32 | { 33 | return self.frame.origin.y; 34 | } 35 | 36 | - (void)setCenterX:(CGFloat)centerX 37 | { 38 | CGPoint center = self.center; 39 | center.x = centerX; 40 | self.center = center; 41 | } 42 | 43 | - (CGFloat)centerX 44 | { 45 | return self.center.x; 46 | } 47 | 48 | - (void)setCenterY:(CGFloat)centerY 49 | { 50 | CGPoint center = self.center; 51 | center.y = centerY; 52 | self.center = center; 53 | } 54 | 55 | - (CGFloat)centerY 56 | { 57 | return self.center.y; 58 | } 59 | 60 | - (void)setWidth:(CGFloat)width 61 | { 62 | CGRect frame = self.frame; 63 | frame.size.width = width; 64 | self.frame = frame; 65 | } 66 | 67 | - (void)setHeight:(CGFloat)height 68 | { 69 | CGRect frame = self.frame; 70 | frame.size.height = height; 71 | self.frame = frame; 72 | } 73 | 74 | - (CGFloat)height 75 | { 76 | return self.frame.size.height; 77 | } 78 | 79 | - (CGFloat)width 80 | { 81 | return self.frame.size.width; 82 | } 83 | 84 | - (void)setSize:(CGSize)size 85 | { 86 | CGRect frame = self.frame; 87 | frame.size = size; 88 | self.frame = frame; 89 | } 90 | 91 | - (CGSize)size 92 | { 93 | return self.frame.size; 94 | } 95 | 96 | - (void)setOrigin:(CGPoint)origin 97 | { 98 | CGRect frame = self.frame; 99 | frame.origin = origin; 100 | self.frame = frame; 101 | } 102 | 103 | - (CGPoint)origin 104 | { 105 | return self.frame.origin; 106 | } 107 | @end 108 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "PQTBDataSource.h" 11 | #import "PQTBDelegate.h" 12 | #import "SectionModel.h" 13 | #import "CellModel.h" 14 | #import "DrawDownloadViewcontroller.h" 15 | @interface ViewController () 16 | @property (weak, nonatomic) IBOutlet UITableView *myTableView; 17 | @property (nonatomic,strong) PQTBDataSource * dataSource; 18 | @property (nonatomic,strong) PQTBDelegate * delegate; 19 | @property (nonatomic,strong) NSMutableArray * array; 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | static NSString * const Identifier = @"cell"; 25 | 26 | - (NSMutableArray *)array{ 27 | if (!_array) { 28 | NSArray * array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Draw" ofType:@"plist"]]; 29 | _array = [NSMutableArray array]; 30 | [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 31 | [_array addObject:[SectionModel sectionWithDict:obj]]; 32 | }]; 33 | } 34 | return _array; 35 | } 36 | 37 | - (void)viewDidLoad { 38 | [super viewDidLoad]; 39 | self.automaticallyAdjustsScrollViewInsets = NO; 40 | self.dataSource = [PQTBDataSource dataSourceWith:self.array identifier:Identifier cellConfigBlock:^(UITableViewCell * _Nullable cell, id _Nullable item) { 41 | cell.textLabel.text = [item name]; 42 | }]; 43 | [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:Identifier]; 44 | self.myTableView.dataSource = self.dataSource; 45 | 46 | self.delegate = [[PQTBDelegate alloc]initWithdelegate:self.array identifier:Identifier cellSelectedBlock:^(id _Nullable cell, id _Nullable item) { 47 | if ([[item controller] isEqualToString:@"DrawDownloadViewController"]) { 48 | DrawDownloadViewcontroller * download = [DrawDownloadViewcontroller loadForStoryboard]; 49 | [self.navigationController pushViewController:download animated:YES]; 50 | } 51 | else{ 52 | Class cls = NSClassFromString([item controller]); 53 | 54 | [self.navigationController pushViewController:[[cls alloc] init] animated:YES]; 55 | } 56 | }]; 57 | self.myTableView.delegate = self.delegate; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/PQDrawTest/back.jpg -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/fore.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/PQDrawTest/fore.jpg -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/jiantou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepgq/DrawDemo/5ab375e6f652cae3098fab4ce81708ff6d8d783b/PQDrawTest/PQDrawTest/jiantou.png -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PQDrawTest 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTestTests/PQDrawTestTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PQDrawTestTests.m 3 | // PQDrawTestTests 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PQDrawTestTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PQDrawTestTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTestUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PQDrawTest/PQDrawTestUITests/PQDrawTestUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PQDrawTestUITests.m 3 | // PQDrawTestUITests 4 | // 5 | // Created by ios on 16/8/13. 6 | // Copyright © 2016年 ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PQDrawTestUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PQDrawTestUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #背景: 2 | > 某天,你正在上班ing……这个时候老大过来了,“小王啊,这个按钮太丑了,客户要求变成五角星形状的,UI没空给你切图,你给我完成这个需求啊”,说完便头也不回的走了,留下你一个人在冷风中摇曳,心里一万只草泥马在狂奔…… 3 | 4 | ![1.png](http://upload-images.jianshu.io/upload_images/1940927-9bdb1a3720f98cab.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 5 | 6 | > OK OK ,自己选的IOS开发,哭着也要完成…… 这里你可能就需要使用绘图这一块的知识了。如果你恰好这块还是比较空白的,那么就是。。。 7 | ![2.gif](http://upload-images.jianshu.io/upload_images/1940927-a60cbbd207607d6e.gif?imageMogr2/auto-orient/strip) 8 | 9 | . 10 | . 11 | . 12 | >没关系,先让我们重drawRect,这个方法开始吧。 13 | 首先了解一下这个东西干嘛的,怎么用,啥时候用。 14 | - 1 干嘛的:如果你要对View进行绘制,那么你就要到这里处理 15 | - 2 怎么用:那当然是在这里涂鸦 16 | - 3 啥时候用:代码说明一切 17 | ``` 18 | -[DrawLineViewcontroller loadView] 19 | -[DrawLineViewcontroller viewDidLoad] 20 | -[DrawLineViewcontroller viewWillAppear:] 21 | -[DrawLineView drawRect:] 22 | -[DrawLineViewcontroller viewDidAppear:] 23 | ``` 24 | 从上述代码我们看到他是在视图将要显示之后和显示之前调用的。 25 | 26 | . 27 | . 28 | . 29 | 通常我们需要进行一下的步骤进行绘制。 30 | > - 1 获取当前的上下文(这里只能获取一次,并且只能在drawRect方法中获取) 31 | - 2 描述路径、形状(就是处理想要显示的样子) 32 | - 3 把描述好的路径、形状添加早上下文中 33 | - 4 显示上下文内容 34 | 35 | . 36 | . 37 | . 38 | > ### 1 画线 39 | - 第一步:先创建一个工程 40 | - 第二步:创建一个View的子类,因为要重写drawRect方法 41 | - 第三步:重写DrawRect 42 | - 第四步:先了解一下线段是如何绘制的,额……两个点确定一条直线,这些东西大家都懂,所以我们需要一个起点和一个终点来确定一条直线。 43 | ![3.png](http://upload-images.jianshu.io/upload_images/1940927-aac1f3d8fea57a7a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 44 | 45 | ###代码如下: 46 | ``` 47 | - (void)drawRect:(CGRect)rect { 48 | // Drawing code 49 | NSLog(@"%s",__func__); 50 | //1.获取上下文 51 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 52 | //2.描述路径 53 | UIBezierPath * path = [UIBezierPath bezierPath]; 54 | //起点 55 | [path moveToPoint:CGPointMake(10, 10)]; 56 | //终点 57 | [path addLineToPoint:CGPointMake(100, 100)]; 58 | //设置颜色 59 | [[UIColor whiteColor]setStroke]; 60 | //3.添加路径 61 | CGContextAddPath(contextRef, path.CGPath); 62 | //显示路径 63 | CGContextStrokePath(contextRef); 64 | 65 | } 66 | ``` 67 | ![4.png](http://upload-images.jianshu.io/upload_images/1940927-fcb288e8749a0227.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 68 | 额外属性:CGContextSetLineWidth(contextRef, 5); //设置线宽 69 | 70 | . 71 | . 72 | . 73 | > ### 1 画矩形 74 | - 第一步:先创建一个工程 75 | - 第二步:创建一个View的子类,因为要重写drawRect方法 76 | - 第三步:重写DrawRect 77 | - 第四步:先了解一下矩形是如何绘制的,矩形是由四个边组成,所以我们画四条线段便可以画一个矩形。 78 | ![5.png](http://upload-images.jianshu.io/upload_images/1940927-9bbb5bf35d266373.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 79 | 80 | 方法一: 81 | ``` 82 | - (void)drawRect:(CGRect)rect { 83 | // Drawing code 84 | 85 | //1.获取上下文 86 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 87 | //2.描述路径 88 | UIBezierPath * path = [UIBezierPath bezierPath]; 89 | //起点 90 | [path moveToPoint:CGPointMake(10, 10)]; 91 | //第二个点 92 | [path addLineToPoint:CGPointMake(100, 10)]; 93 | //第三个点 94 | [path addLineToPoint:CGPointMake(100, 100)]; 95 | //第四个点 96 | [path addLineToPoint:CGPointMake(10, 100)]; 97 | //闭合路径 也等于 [path addLineToPoint:CGPointMake(10, 10)]; 98 | [path closePath]; 99 | //设置颜色 100 | [[UIColor greenColor]setStroke]; 101 | //3.添加路径 102 | CGContextAddPath(contextRef, path.CGPath); 103 | //显示路径 104 | CGContextStrokePath(contextRef); 105 | } 106 | ``` 107 | 效果图 108 | ![方法一](http://upload-images.jianshu.io/upload_images/1940927-3071c77b4dd8bb25.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 109 | 110 | 方法二:通过一个起点和宽高,可计算出来矩形的大小位置 111 | ``` 112 | - (void)drawRect:(CGRect)rect { 113 | // Drawing code 114 | 115 | //1.获取上下文 116 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 117 | //2.描述路径 118 | UIBezierPath * path = [UIBezierPath bezierPathWithRect:CGRectMake(10, 10, 100, 100)]; 119 | //设置颜色 120 | [[UIColor greenColor]set]; 121 | //3.添加路径 122 | CGContextAddPath(contextRef, path.CGPath); 123 | //显示路径 124 | CGContextFillPath(contextRef); 125 | 126 | } 127 | ``` 128 | 效果图: 129 | ![方法二](http://upload-images.jianshu.io/upload_images/1940927-bf701f6718a690b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 130 | 131 | #### 画矩形总结:stroke:描边 、 fill:填充 132 | > //设置描边颜色 133 | [[UIColor greenColor]setStroke]; 134 | //显示描边路径 135 | CGContextStrokePath(contextRef); 136 | //设置填充颜色 137 | [[UIColor greenColor]set]; 138 | //显示填充路径 139 | CGContextFillPath(contextRef); 140 | 141 | . 142 | . 143 | . 144 | > ### 3 画圆 145 | - 第一步:先创建一个工程 146 | - 第二步:创建一个View的子类,因为要重写drawRect方法 147 | - 第三步:重写DrawRect 148 | - 第四步:先了解一下圆形是如何绘制的,要确定圆心、半径,以及旋转的角度。 149 | ![圆](http://upload-images.jianshu.io/upload_images/1940927-3af998b2f2567519.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 150 | 151 | 方法一: 152 | ``` 153 | - (void)drawRect:(CGRect)rect { 154 | // Drawing code 155 | 156 | //1、获取当前上下文 157 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 158 | //2.描述路径 159 | //ArcCenter:中心点 160 | //radius:半径 161 | //startAngle:起始角度 162 | //endAngle:结束角度 163 | //clockwise:是否逆时针 164 | UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width*0.5, self.bounds.size.height*0.5) radius:self.bounds.size.width*0.4 startAngle:0 endAngle:M_PI*2 clockwise:NO]; 165 | //3.添加路径到上下文 166 | CGContextAddPath(contextRef, path.CGPath); 167 | //4.设置颜色 168 | [[UIColor brownColor]setFill]; 169 | //4.显示上下文 显示一个实心圆 170 | // CGContextFillPath(contextRef); 171 | //显示一个空心圆,描边 172 | CGContextStrokePath(contextRef); 173 | } 174 | ``` 175 | 效果图: 176 | ![效果图](http://upload-images.jianshu.io/upload_images/1940927-068c2341f1d2b35d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 177 | 178 | 方法二:通过话椭圆的方式去画圆,大家都知道圆就是椭圆的一个特殊存在。宽高一致的时候就是圆形。 179 | ``` 180 | - (void)drawRect:(CGRect)rect { 181 | // Drawing code 182 | 183 | //1、获取当前上下文 184 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 185 | //2.描述路径 这是画椭圆的方法,大家都知道 186 | UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(10, 10, 100, 100)]; 187 | //3.添加路径到上下文 188 | CGContextAddPath(contextRef, path.CGPath); 189 | //4.设置颜色 190 | [[UIColor redColor]setFill]; 191 | //4.显示上下文 192 | CGContextFillPath(contextRef); 193 | 194 | } 195 | ``` 196 | 197 | ![效果图](http://upload-images.jianshu.io/upload_images/1940927-08a123ea1baf0829.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 198 | 199 | . 200 | . 201 | . 202 | > ### 4 画文字 203 | - 第一步:先创建一个工程 204 | - 第二步:创建一个View的子类,因为要重写drawRect方法 205 | - 第三步:重写DrawRect 206 | - 第四步:写一段文字,把文字绘制到上下文中 207 | 208 | ``` 209 | - (void)drawRect:(CGRect)rect { 210 | // Drawing code 211 | 212 | //1.获取当前上下文 213 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 214 | //2.创建文字 215 | NSString * str = @"纸巾艺术"; 216 | //会知道上下文 217 | [str drawInRect:rect withAttributes:nil]; 218 | CGContextStrokePath(contextRef); 219 | } 220 | ``` 221 | 222 | ![基本版效果图](http://upload-images.jianshu.io/upload_images/1940927-dd602dfc189cb61a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 223 | 224 | 复杂版: 225 | ``` 226 | - (void)drawRect:(CGRect)rect { 227 | // Drawing code 228 | 229 | //1.获取当前上下文 230 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 231 | //2.创建文字 232 | NSString * str = @"纸巾艺术"; 233 | //设置字体样式 234 | NSMutableDictionary * dict = [NSMutableDictionary dictionary]; 235 | //NSFontAttributeName:字体大小 236 | dict[NSFontAttributeName] = [UIFont systemFontOfSize:25]; 237 | //字体前景色 238 | dict[NSForegroundColorAttributeName] = [UIColor blueColor]; 239 | //字体背景色 240 | dict[NSBackgroundColorAttributeName] = [UIColor redColor]; 241 | //字体阴影 242 | NSShadow * shadow = [[NSShadow alloc]init]; 243 | //阴影偏移量 244 | shadow.shadowOffset = CGSizeMake(2, 2); 245 | //阴影颜色 246 | shadow.shadowColor = [UIColor greenColor]; 247 | //高斯模糊 248 | shadow.shadowBlurRadius = 5; 249 | dict[NSShadowAttributeName] = shadow; 250 | //字体间距 251 | dict[NSKernAttributeName] = @10; 252 | //绘制到上下文 253 | //从某一点开始绘制 默认 0 0点 254 | // [str drawAtPoint:CGPointMake(100, 100) withAttributes:nil]; 255 | //绘制区域设置 256 | [str drawInRect:rect withAttributes:dict]; 257 | //添加到上下文 258 | CGContextStrokePath(contextRef); 259 | } 260 | ``` 261 | ![复杂版效果图](http://upload-images.jianshu.io/upload_images/1940927-a1420eabb801ca97.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 262 | 263 | . 264 | . 265 | . 266 | > ### 5 画图片 267 | - 第一步:先创建一个工程 268 | - 第二步:创建一个View的子类,因为要重写drawRect方法 269 | - 第三步:重写DrawRect 270 | - 第四步:加载一张图片,绘制到上下文中 271 | 272 | ``` 273 | - (void)drawRect:(CGRect)rect { 274 | // Drawing code 275 | 276 | //1.获取当前的上下文 277 | CGContextRef contextRef = UIGraphicsGetCurrentContext(); 278 | //2.加载图片 279 | //这里顺便咯嗦一句:使用imageNamed加载图片是会有缓存的 280 | //我们这里只需要加载一次就够了,不需要多次加载,所以不应该保存这个缓存 281 | // UIImage * image = [UIImage imageNamed:@"222"]; //所以可以换一种方式去加载 282 | UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"222.png" ofType:nil]]; 283 | 284 | 285 | // //绘制的大小位置 286 | // [image drawInRect:rect]; 287 | 288 | 289 | // //从某个点开始绘制 290 | // [image drawAtPoint:CGPointMake(0, 0)]; 291 | 292 | 293 | //绘制一个多大的图片,并且设置他的混合模式以及透明度 294 | //Rect:大小位置 295 | //blendModel:混合模式 296 | //alpha:透明度 297 | [image drawInRect:rect blendMode:kCGBlendModeNormal alpha:1]; 298 | 299 | 300 | //从某一点开始绘制图片,并设置混合模式以及透明度 301 | //point:开始位置 302 | //blendModel:混合模式 303 | //alpha:透明度 304 | // [image drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:1]; 305 | 306 | //添加到上下文 307 | CGContextFillPath(contextRef); 308 | } 309 | ``` 310 | ![都写一起了!!!](http://upload-images.jianshu.io/upload_images/1940927-c4b0966988c7afc0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 311 | 312 | 313 | . 314 | . 315 | . 316 | . 317 | . 318 | > ### 6 综合实例: 319 | > > #### 1 重绘 320 | 实现一个下载进度条 321 | - 第一步:先创建一个工程 322 | - 第二步:创建一个View的子类,因为要重写drawRect方法 323 | - 第三步:重写DrawRect 324 | - 第四步:加载一张图片,绘制到上下文中 325 | 326 | ``` 327 | - (void)drawRect:(CGRect)rect { 328 | 329 | CGFloat startA = - M_PI_2; 330 | CGFloat endA = - M_PI_2 + self.progress * M_PI * 2; 331 | NSLog(@"%f - %f - %f",self.progress,(3.14159265359*self.progress)/180,endA); 332 | UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width*0.5, self.bounds.size.height*0.5) radius:self.bounds.size.width*0.5-10 startAngle:startA endAngle:endA clockwise:YES]; 333 | [path stroke]; 334 | 335 | } 336 | ``` 337 | 这里我们可以看到我并没有获取当前的上下文,这里是因为[path stroke]; 已经帮我们完成了其余的操作。 338 | 其实内部实现还是一样的!! 339 | 基本版效果: 340 | ![基本版效果](http://upload-images.jianshu.io/upload_images/1940927-0efb7b4bf573ca67.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 341 | 高能版:上面的只是完成了功能,但是却不好看!!然后我们稍稍的美化一下 342 | 343 | ``` 344 | - (void)drawRect:(CGRect)rect { 345 | 346 | CGFloat startA = - M_PI_2; 347 | CGFloat endA = - M_PI_2 + self.progress * M_PI * 2; 348 | NSLog(@"%f - %f - %f",self.progress,(3.14159265359*self.progress)/180,endA); 349 | UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width*0.5, self.bounds.size.height*0.5) radius:self.bounds.size.width*0.5-10 startAngle:startA endAngle:endA clockwise:YES]; 350 | [[UIColor colorWithRed:self.progress green:(1-self.progress) blue:0 alpha:1]setStroke]; 351 | path.lineWidth = 5; 352 | [path stroke]; 353 | 354 | } 355 | ``` 356 | 357 | ![动画版](http://upload-images.jianshu.io/upload_images/1940927-9849444675aa76a8.gif?imageMogr2/auto-orient/strip) 358 | . 359 | . 360 | . 361 | . 362 | . 363 | > > #### 2 不同颜色的线 364 | 先跑出问题! 365 | ![线](http://upload-images.jianshu.io/upload_images/1940927-76fcf91d042252ba.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 366 | 这种线怎么处理!我们先实现三条线 367 | 368 | ``` 369 | - (void)drawRect:(CGRect)rect { 370 | // Drawing code 371 | 372 | UIBezierPath * path = [UIBezierPath bezierPath]; 373 | //设置线宽 374 | path.lineWidth = 5; 375 | 376 | //第一条线 377 | [[UIColor purpleColor]setStroke]; 378 | [path moveToPoint:CGPointMake(10, 10)]; 379 | [path addLineToPoint:CGPointMake(10, 100)]; 380 | 381 | //第二条线 382 | [[UIColor orangeColor]setStroke]; 383 | [path moveToPoint:CGPointMake(30, 10)]; 384 | [path addLineToPoint:CGPointMake(30, 100)]; 385 | 386 | //第三条线 387 | [[UIColor greenColor]setStroke]; 388 | [path moveToPoint:CGPointMake(50, 10)]; 389 | [path addLineToPoint:CGPointMake(50, 100)]; 390 | 391 | //使用描边方式添加到上下文中 392 | [path stroke]; 393 | } 394 | ``` 395 | 你可能想当然的就这么做了,可是你发现效果是这样子的!!! 396 | ![哎呀我去,为什么](http://upload-images.jianshu.io/upload_images/1940927-b1a121e0bb6b58de.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 397 | 其实是这样子的 398 | 399 | ![先设置了紫色](http://upload-images.jianshu.io/upload_images/1940927-2a528d99a2743299.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 400 | ![设置了橙色](http://upload-images.jianshu.io/upload_images/1940927-42068017dfefc6f9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 401 | 402 | ![设置了绿色](http://upload-images.jianshu.io/upload_images/1940927-b23809a65d019604.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 403 | 404 | 所以,最后显示的就是绿色!!!! 405 | 406 | 这里我们还要了解一个东西! 407 | 上下文的状态栈。 408 | 409 | ![21.png](http://upload-images.jianshu.io/upload_images/1940927-3b92a7f68bff61ab.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 410 | 411 | 412 | 方法一: 413 | ``` 414 | - (void)drawRect:(CGRect)rect { 415 | // Drawing code 416 | 417 | 418 | //1 获取上下文 419 | //分别设置线段的颜色 420 | CGContextRef purple = UIGraphicsGetCurrentContext(); 421 | [[UIColor purpleColor]setStroke]; 422 | CGContextSaveGState(purple); 423 | 424 | CGContextRef orange = UIGraphicsGetCurrentContext(); 425 | [[UIColor orangeColor]setStroke]; 426 | CGContextSaveGState(orange); 427 | 428 | CGContextRef green = UIGraphicsGetCurrentContext(); 429 | [[UIColor greenColor]setStroke]; 430 | CGContextSaveGState(green); 431 | 432 | 433 | UIBezierPath * path = [UIBezierPath bezierPath]; 434 | //设置线宽 435 | path.lineWidth = 5; 436 | 437 | //把紫色的上下文从栈中取出来 438 | CGContextRestoreGState(purple); 439 | //第一条线 440 | [[UIColor purpleColor]setStroke]; 441 | [path moveToPoint:CGPointMake(10, 10)]; 442 | [path addLineToPoint:CGPointMake(10, 100)]; 443 | [path stroke]; 444 | 445 | 446 | //把紫色的上下文从栈中取出来 447 | CGContextRestoreGState(orange); 448 | path = [UIBezierPath bezierPath]; 449 | //设置线宽 450 | path.lineWidth = 9; 451 | //第二条线 452 | [[UIColor orangeColor]setStroke]; 453 | [path moveToPoint:CGPointMake(30, 10)]; 454 | [path addLineToPoint:CGPointMake(30, 100)]; 455 | [path stroke]; 456 | 457 | //把紫色的上下文从栈中取出来 458 | CGContextRestoreGState(green); 459 | path = [UIBezierPath bezierPath]; 460 | //设置线宽 461 | path.lineWidth = 3; 462 | //第三条线 463 | [[UIColor greenColor]setStroke]; 464 | [path moveToPoint:CGPointMake(50, 10)]; 465 | [path addLineToPoint:CGPointMake(50, 100)]; 466 | [path stroke]; 467 | } 468 | ``` 469 | 方法二: 470 | 471 | ``` 472 | - (void)drawRect:(CGRect)rect { 473 | // Drawing code 474 | 475 | [[self bezierPathWithPoint:CGPointMake(10, 10) endPoint:CGPointMake(10, 180) lineColor:[UIColor purpleColor] lineWidth:6] stroke]; 476 | [[self bezierPathWithPoint:CGPointMake(50, 10) endPoint:CGPointMake(50, 180) lineColor:[UIColor greenColor] lineWidth:6] stroke]; 477 | [[self bezierPathWithPoint:CGPointMake(90, 10) endPoint:CGPointMake(90, 180) lineColor:[UIColor orangeColor] lineWidth:6] stroke]; 478 | 479 | } 480 | 481 | - (UIBezierPath *)bezierPathWithPoint:(CGPoint)startPoint endPoint:(CGPoint) endPoint lineColor:(UIColor*)lineColor lineWidth:(CGFloat)lineWidth{ 482 | UIBezierPath * path = [UIBezierPath bezierPath]; 483 | [lineColor setStroke]; 484 | path.lineWidth = lineWidth; 485 | [path moveToPoint:startPoint]; 486 | [path addLineToPoint:endPoint]; 487 | 488 | return path; 489 | } 490 | ``` 491 | 492 | ![了解了原理之后就这样子写快点啦 ](http://upload-images.jianshu.io/upload_images/1940927-f6101934d8627660.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 493 | 494 |
495 | 2017年12月11日 496 | ####新增渐变色的绘制:方案一使用CGContextDrawLinearGradient去做 497 | 498 | 499 |
500 | 新建一个View在Controller中加载他,然后实现如下代码,注释比较详细,就不在说明了。 501 | ``` 502 | - (void)drawRect:(CGRect)rect { 503 | 504 | //画线 505 | [self drawLine]; 506 | 507 | //画一个渐变色的线 508 | [self drawLineWithStartColor:[UIColor redColor] endColor:[UIColor greenColor]]; 509 | } 510 | 511 | - (void)drawLineWithStartColor:(UIColor *)startColor endColor:(UIColor *)endColor{ 512 | //1、获取上下文 513 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 514 | 515 | //3、创建一个颜色空间 516 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 517 | //4、设置颜色的location 518 | CGFloat locations[] = { 0.0, 1.0 }; 519 | //5、创建一个颜色数组,由于NSArray里面只能存对象,所以需要桥接 520 | NSArray *colors = @[(__bridge id)startColor.CGColor,(__bridge id)endColor.CGColor]; 521 | 522 | CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations); 523 | //释放 524 | CFRelease(colorSpace); 525 | 526 | //保存一份当前上下文,压栈 527 | CGContextSaveGState(ctx); 528 | 529 | //绘制一个矩形,矩形足够小,也可以是一条线 530 | CGFloat width = self.frame.size.width; 531 | CGContextMoveToPoint(ctx, 0, 120); 532 | CGContextAddLineToPoint(ctx, width, 120); 533 | CGContextAddLineToPoint(ctx, width, 123); 534 | CGContextAddLineToPoint(ctx, 0, 123); 535 | //裁剪 536 | CGContextEOClip(ctx); 537 | 538 | //绘制渐变 539 | CGContextDrawLinearGradient(ctx, gradient, CGPointMake(0, 100), CGPointMake(self.frame.size.width, 100), kCGGradientDrawsBeforeStartLocation); 540 | 541 | //恢复一份当前的上下文,出栈 542 | CGContextRestoreGState(ctx); 543 | 544 | //释放内存 545 | CGColorSpaceRelease(colorSpace); 546 | CGGradientRelease(gradient); 547 | } 548 | 549 | - (void)drawLine{ 550 | //1、获取上下文 551 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 552 | 553 | //2画一条直线的需要知道的就是两个点,也就是起点和终点 554 | //2.1、选择一个点最为画线的起点 555 | CGContextMoveToPoint(ctx, 0, 100); 556 | //2.2、设置线的终点 557 | CGContextAddLineToPoint(ctx, 300, 100); 558 | 559 | CGContextSetLineWidth(ctx, 3); 560 | 561 | //3、填充路径 填充路径的方法有两个 一个是 stroke(描边) 一个 fill(填充) 562 | CGContextStrokePath(ctx);// 类似于描边 563 | 564 | //4、释放内存 565 | CGContextRelease(ctx); 566 | } 567 | ``` 568 |
569 |
570 | #### 方案二使用CAGradientLayer去做 571 | ``` 572 | CAGradientLayer * layer = [CAGradientLayer layer]; 573 | //设置大小 574 | layer.frame = CGRectMake(0, 400, 300, 3); 575 | //设置颜色 576 | layer.colors = @[(__bridge id)[UIColor colorWithRed:204.0 / 255.0 green:224.0 / 255.0 blue:244.0 / 255.0 alpha:1].CGColor, 577 | (__bridge id)[UIColor colorWithRed:29.0 / 255.0 green:156.0 / 255.0 blue:215.0 / 255.0 alpha:1].CGColor, 578 | (__bridge id)[UIColor colorWithRed:0.0 / 255.0 green:50.0 / 255.0 blue:126.0 / 255.0 alpha:1].CGColor]; 579 | //渐变层的相对位置,起始点为0,终止点为1,中间点为 (point-startpoint)/(endpoint-startpoint) 580 | layer.locations = @[@0,@.5,@1]; 581 | //渐变方向 582 | layer.startPoint = CGPointMake(0, 1); 583 | layer.endPoint = CGPointMake(1, 1); 584 | [self.view.layer addSublayer:layer]; 585 | ``` 586 | ![最终效果](http://upload-images.jianshu.io/upload_images/1940927-e8524a83c2907b7d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 587 | 588 | 589 | 590 |
591 | ## [demo地址](https://github.com/codepgq/DrawDemo) 592 | ####下一篇:[图形上下文](http://www.jianshu.com/p/4e22c6ac114d) 593 | --------------------------------------------------------------------------------