├── .gitignore ├── LICENSE ├── LrdAlert.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Up.xcuserdatad │ └── xcschemes │ ├── LrdAlert.xcscheme │ └── xcschememanagement.plist ├── LrdAlert ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── LrdAlertView │ ├── LrdAlertTableView.h │ ├── LrdAlertTableView.m │ ├── LrdDateModel.h │ ├── LrdDateModel.m │ ├── LrdTableViewCell.h │ ├── LrdTableViewCell.m │ └── close_icon@2x.png ├── LrdCameraAlertView │ ├── CameraAlertView.h │ └── CameraAlertView.m ├── LrdPasswordAlertView │ ├── LrdPasswordAlertView.h │ ├── LrdPasswordAlertView.m │ ├── WTReParser.h │ ├── WTReParser.m │ ├── WTReTextField.h │ ├── WTReTextField.m │ └── close_icon@2x.png ├── Masonry │ ├── MASCompositeConstraint.h │ ├── MASCompositeConstraint.m │ ├── MASConstraint+Private.h │ ├── MASConstraint.h │ ├── MASConstraint.m │ ├── MASConstraintMaker.h │ ├── MASConstraintMaker.m │ ├── MASLayoutConstraint.h │ ├── MASLayoutConstraint.m │ ├── MASUtilities.h │ ├── MASViewAttribute.h │ ├── MASViewAttribute.m │ ├── MASViewConstraint.h │ ├── MASViewConstraint.m │ ├── Masonry.h │ ├── NSArray+MASAdditions.h │ ├── NSArray+MASAdditions.m │ ├── NSArray+MASShorthandAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.m │ ├── View+MASAdditions.h │ ├── View+MASAdditions.m │ ├── View+MASShorthandAdditions.h │ ├── ViewController+MASAdditions.h │ └── ViewController+MASAdditions.m ├── ViewController.h ├── ViewController.m └── main.m ├── LrdAlertTests ├── Info.plist └── LrdAlertTests.m ├── LrdAlertUITests ├── Info.plist └── LrdAlertUITests.m └── README.md /.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 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 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/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LrdAlert.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F515EB8F1CA980D50038810A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EB8E1CA980D50038810A /* main.m */; }; 11 | F515EB921CA980D50038810A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EB911CA980D50038810A /* AppDelegate.m */; }; 12 | F515EB951CA980D50038810A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EB941CA980D50038810A /* ViewController.m */; }; 13 | F515EB981CA980D50038810A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F515EB961CA980D50038810A /* Main.storyboard */; }; 14 | F515EB9A1CA980D50038810A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F515EB991CA980D50038810A /* Assets.xcassets */; }; 15 | F515EB9D1CA980D50038810A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F515EB9B1CA980D50038810A /* LaunchScreen.storyboard */; }; 16 | F515EBA81CA980D60038810A /* LrdAlertTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBA71CA980D60038810A /* LrdAlertTests.m */; }; 17 | F515EBB31CA980D60038810A /* LrdAlertUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBB21CA980D60038810A /* LrdAlertUITests.m */; }; 18 | F515EBED1CA980E50038810A /* close_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F515EBC11CA980E50038810A /* close_icon@2x.png */; }; 19 | F515EBEE1CA980E50038810A /* LrdAlertTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBC31CA980E50038810A /* LrdAlertTableView.m */; }; 20 | F515EBEF1CA980E50038810A /* LrdDateModel.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBC51CA980E50038810A /* LrdDateModel.m */; }; 21 | F515EBF01CA980E50038810A /* LrdTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBC71CA980E50038810A /* LrdTableViewCell.m */; }; 22 | F515EBF11CA980E50038810A /* CameraAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBCA1CA980E50038810A /* CameraAlertView.m */; }; 23 | F515EBF21CA980E50038810A /* close_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F515EBCC1CA980E50038810A /* close_icon@2x.png */; }; 24 | F515EBF31CA980E50038810A /* LrdPasswordAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBCE1CA980E50038810A /* LrdPasswordAlertView.m */; }; 25 | F515EBF41CA980E50038810A /* WTReParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBD01CA980E50038810A /* WTReParser.m */; }; 26 | F515EBF51CA980E50038810A /* WTReTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBD21CA980E50038810A /* WTReTextField.m */; }; 27 | F515EBF61CA980E50038810A /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBD51CA980E50038810A /* MASCompositeConstraint.m */; }; 28 | F515EBF71CA980E50038810A /* MASConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBD81CA980E50038810A /* MASConstraint.m */; }; 29 | F515EBF81CA980E50038810A /* MASConstraintMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBDA1CA980E50038810A /* MASConstraintMaker.m */; }; 30 | F515EBF91CA980E50038810A /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBDC1CA980E50038810A /* MASLayoutConstraint.m */; }; 31 | F515EBFA1CA980E50038810A /* MASViewAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBE01CA980E50038810A /* MASViewAttribute.m */; }; 32 | F515EBFB1CA980E50038810A /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBE21CA980E50038810A /* MASViewConstraint.m */; }; 33 | F515EBFC1CA980E50038810A /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBE41CA980E50038810A /* NSArray+MASAdditions.m */; }; 34 | F515EBFD1CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBE71CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.m */; }; 35 | F515EBFE1CA980E50038810A /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBE91CA980E50038810A /* View+MASAdditions.m */; }; 36 | F515EBFF1CA980E50038810A /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F515EBEC1CA980E50038810A /* ViewController+MASAdditions.m */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXContainerItemProxy section */ 40 | F515EBA41CA980D60038810A /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = F515EB821CA980D50038810A /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = F515EB891CA980D50038810A; 45 | remoteInfo = LrdAlert; 46 | }; 47 | F515EBAF1CA980D60038810A /* PBXContainerItemProxy */ = { 48 | isa = PBXContainerItemProxy; 49 | containerPortal = F515EB821CA980D50038810A /* Project object */; 50 | proxyType = 1; 51 | remoteGlobalIDString = F515EB891CA980D50038810A; 52 | remoteInfo = LrdAlert; 53 | }; 54 | /* End PBXContainerItemProxy section */ 55 | 56 | /* Begin PBXFileReference section */ 57 | F515EB8A1CA980D50038810A /* LrdAlert.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LrdAlert.app; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | F515EB8E1CA980D50038810A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 59 | F515EB901CA980D50038810A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 60 | F515EB911CA980D50038810A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 61 | F515EB931CA980D50038810A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 62 | F515EB941CA980D50038810A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 63 | F515EB971CA980D50038810A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 64 | F515EB991CA980D50038810A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 65 | F515EB9C1CA980D50038810A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 66 | F515EB9E1CA980D50038810A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 67 | F515EBA31CA980D60038810A /* LrdAlertTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LrdAlertTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | F515EBA71CA980D60038810A /* LrdAlertTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LrdAlertTests.m; sourceTree = ""; }; 69 | F515EBA91CA980D60038810A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | F515EBAE1CA980D60038810A /* LrdAlertUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LrdAlertUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | F515EBB21CA980D60038810A /* LrdAlertUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LrdAlertUITests.m; sourceTree = ""; }; 72 | F515EBB41CA980D60038810A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | F515EBC11CA980E50038810A /* close_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "close_icon@2x.png"; sourceTree = ""; }; 74 | F515EBC21CA980E50038810A /* LrdAlertTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LrdAlertTableView.h; sourceTree = ""; }; 75 | F515EBC31CA980E50038810A /* LrdAlertTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LrdAlertTableView.m; sourceTree = ""; }; 76 | F515EBC41CA980E50038810A /* LrdDateModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LrdDateModel.h; sourceTree = ""; }; 77 | F515EBC51CA980E50038810A /* LrdDateModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LrdDateModel.m; sourceTree = ""; }; 78 | F515EBC61CA980E50038810A /* LrdTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LrdTableViewCell.h; sourceTree = ""; }; 79 | F515EBC71CA980E50038810A /* LrdTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LrdTableViewCell.m; sourceTree = ""; }; 80 | F515EBC91CA980E50038810A /* CameraAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraAlertView.h; sourceTree = ""; }; 81 | F515EBCA1CA980E50038810A /* CameraAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraAlertView.m; sourceTree = ""; }; 82 | F515EBCC1CA980E50038810A /* close_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "close_icon@2x.png"; sourceTree = ""; }; 83 | F515EBCD1CA980E50038810A /* LrdPasswordAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LrdPasswordAlertView.h; sourceTree = ""; }; 84 | F515EBCE1CA980E50038810A /* LrdPasswordAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LrdPasswordAlertView.m; sourceTree = ""; }; 85 | F515EBCF1CA980E50038810A /* WTReParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTReParser.h; sourceTree = ""; }; 86 | F515EBD01CA980E50038810A /* WTReParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WTReParser.m; sourceTree = ""; }; 87 | F515EBD11CA980E50038810A /* WTReTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTReTextField.h; sourceTree = ""; }; 88 | F515EBD21CA980E50038810A /* WTReTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WTReTextField.m; sourceTree = ""; }; 89 | F515EBD41CA980E50038810A /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = ""; }; 90 | F515EBD51CA980E50038810A /* MASCompositeConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASCompositeConstraint.m; sourceTree = ""; }; 91 | F515EBD61CA980E50038810A /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = ""; }; 92 | F515EBD71CA980E50038810A /* MASConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraint.h; sourceTree = ""; }; 93 | F515EBD81CA980E50038810A /* MASConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraint.m; sourceTree = ""; }; 94 | F515EBD91CA980E50038810A /* MASConstraintMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASConstraintMaker.h; sourceTree = ""; }; 95 | F515EBDA1CA980E50038810A /* MASConstraintMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASConstraintMaker.m; sourceTree = ""; }; 96 | F515EBDB1CA980E50038810A /* MASLayoutConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLayoutConstraint.h; sourceTree = ""; }; 97 | F515EBDC1CA980E50038810A /* MASLayoutConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLayoutConstraint.m; sourceTree = ""; }; 98 | F515EBDD1CA980E50038810A /* Masonry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Masonry.h; sourceTree = ""; }; 99 | F515EBDE1CA980E50038810A /* MASUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASUtilities.h; sourceTree = ""; }; 100 | F515EBDF1CA980E50038810A /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = ""; }; 101 | F515EBE01CA980E50038810A /* MASViewAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewAttribute.m; sourceTree = ""; }; 102 | F515EBE11CA980E50038810A /* MASViewConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewConstraint.h; sourceTree = ""; }; 103 | F515EBE21CA980E50038810A /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = ""; }; 104 | F515EBE31CA980E50038810A /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = ""; }; 105 | F515EBE41CA980E50038810A /* NSArray+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASAdditions.m"; sourceTree = ""; }; 106 | F515EBE51CA980E50038810A /* NSArray+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASShorthandAdditions.h"; sourceTree = ""; }; 107 | F515EBE61CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSLayoutConstraint+MASDebugAdditions.h"; sourceTree = ""; }; 108 | F515EBE71CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = ""; }; 109 | F515EBE81CA980E50038810A /* View+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASAdditions.h"; sourceTree = ""; }; 110 | F515EBE91CA980E50038810A /* View+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "View+MASAdditions.m"; sourceTree = ""; }; 111 | F515EBEA1CA980E50038810A /* View+MASShorthandAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "View+MASShorthandAdditions.h"; sourceTree = ""; }; 112 | F515EBEB1CA980E50038810A /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = ""; }; 113 | F515EBEC1CA980E50038810A /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = ""; }; 114 | /* End PBXFileReference section */ 115 | 116 | /* Begin PBXFrameworksBuildPhase section */ 117 | F515EB871CA980D50038810A /* Frameworks */ = { 118 | isa = PBXFrameworksBuildPhase; 119 | buildActionMask = 2147483647; 120 | files = ( 121 | ); 122 | runOnlyForDeploymentPostprocessing = 0; 123 | }; 124 | F515EBA01CA980D60038810A /* Frameworks */ = { 125 | isa = PBXFrameworksBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | ); 129 | runOnlyForDeploymentPostprocessing = 0; 130 | }; 131 | F515EBAB1CA980D60038810A /* Frameworks */ = { 132 | isa = PBXFrameworksBuildPhase; 133 | buildActionMask = 2147483647; 134 | files = ( 135 | ); 136 | runOnlyForDeploymentPostprocessing = 0; 137 | }; 138 | /* End PBXFrameworksBuildPhase section */ 139 | 140 | /* Begin PBXGroup section */ 141 | F515EB811CA980D50038810A = { 142 | isa = PBXGroup; 143 | children = ( 144 | F515EB8C1CA980D50038810A /* LrdAlert */, 145 | F515EBA61CA980D60038810A /* LrdAlertTests */, 146 | F515EBB11CA980D60038810A /* LrdAlertUITests */, 147 | F515EB8B1CA980D50038810A /* Products */, 148 | ); 149 | sourceTree = ""; 150 | }; 151 | F515EB8B1CA980D50038810A /* Products */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | F515EB8A1CA980D50038810A /* LrdAlert.app */, 155 | F515EBA31CA980D60038810A /* LrdAlertTests.xctest */, 156 | F515EBAE1CA980D60038810A /* LrdAlertUITests.xctest */, 157 | ); 158 | name = Products; 159 | sourceTree = ""; 160 | }; 161 | F515EB8C1CA980D50038810A /* LrdAlert */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | F515EBC01CA980E50038810A /* LrdAlertView */, 165 | F515EBC81CA980E50038810A /* LrdCameraAlertView */, 166 | F515EBCB1CA980E50038810A /* LrdPasswordAlertView */, 167 | F515EBD31CA980E50038810A /* Masonry */, 168 | F515EB901CA980D50038810A /* AppDelegate.h */, 169 | F515EB911CA980D50038810A /* AppDelegate.m */, 170 | F515EB931CA980D50038810A /* ViewController.h */, 171 | F515EB941CA980D50038810A /* ViewController.m */, 172 | F515EB961CA980D50038810A /* Main.storyboard */, 173 | F515EB991CA980D50038810A /* Assets.xcassets */, 174 | F515EB9B1CA980D50038810A /* LaunchScreen.storyboard */, 175 | F515EB9E1CA980D50038810A /* Info.plist */, 176 | F515EB8D1CA980D50038810A /* Supporting Files */, 177 | ); 178 | path = LrdAlert; 179 | sourceTree = ""; 180 | }; 181 | F515EB8D1CA980D50038810A /* Supporting Files */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | F515EB8E1CA980D50038810A /* main.m */, 185 | ); 186 | name = "Supporting Files"; 187 | sourceTree = ""; 188 | }; 189 | F515EBA61CA980D60038810A /* LrdAlertTests */ = { 190 | isa = PBXGroup; 191 | children = ( 192 | F515EBA71CA980D60038810A /* LrdAlertTests.m */, 193 | F515EBA91CA980D60038810A /* Info.plist */, 194 | ); 195 | path = LrdAlertTests; 196 | sourceTree = ""; 197 | }; 198 | F515EBB11CA980D60038810A /* LrdAlertUITests */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | F515EBB21CA980D60038810A /* LrdAlertUITests.m */, 202 | F515EBB41CA980D60038810A /* Info.plist */, 203 | ); 204 | path = LrdAlertUITests; 205 | sourceTree = ""; 206 | }; 207 | F515EBC01CA980E50038810A /* LrdAlertView */ = { 208 | isa = PBXGroup; 209 | children = ( 210 | F515EBC11CA980E50038810A /* close_icon@2x.png */, 211 | F515EBC21CA980E50038810A /* LrdAlertTableView.h */, 212 | F515EBC31CA980E50038810A /* LrdAlertTableView.m */, 213 | F515EBC41CA980E50038810A /* LrdDateModel.h */, 214 | F515EBC51CA980E50038810A /* LrdDateModel.m */, 215 | F515EBC61CA980E50038810A /* LrdTableViewCell.h */, 216 | F515EBC71CA980E50038810A /* LrdTableViewCell.m */, 217 | ); 218 | path = LrdAlertView; 219 | sourceTree = ""; 220 | }; 221 | F515EBC81CA980E50038810A /* LrdCameraAlertView */ = { 222 | isa = PBXGroup; 223 | children = ( 224 | F515EBC91CA980E50038810A /* CameraAlertView.h */, 225 | F515EBCA1CA980E50038810A /* CameraAlertView.m */, 226 | ); 227 | path = LrdCameraAlertView; 228 | sourceTree = ""; 229 | }; 230 | F515EBCB1CA980E50038810A /* LrdPasswordAlertView */ = { 231 | isa = PBXGroup; 232 | children = ( 233 | F515EBCC1CA980E50038810A /* close_icon@2x.png */, 234 | F515EBCD1CA980E50038810A /* LrdPasswordAlertView.h */, 235 | F515EBCE1CA980E50038810A /* LrdPasswordAlertView.m */, 236 | F515EBCF1CA980E50038810A /* WTReParser.h */, 237 | F515EBD01CA980E50038810A /* WTReParser.m */, 238 | F515EBD11CA980E50038810A /* WTReTextField.h */, 239 | F515EBD21CA980E50038810A /* WTReTextField.m */, 240 | ); 241 | path = LrdPasswordAlertView; 242 | sourceTree = ""; 243 | }; 244 | F515EBD31CA980E50038810A /* Masonry */ = { 245 | isa = PBXGroup; 246 | children = ( 247 | F515EBD41CA980E50038810A /* MASCompositeConstraint.h */, 248 | F515EBD51CA980E50038810A /* MASCompositeConstraint.m */, 249 | F515EBD61CA980E50038810A /* MASConstraint+Private.h */, 250 | F515EBD71CA980E50038810A /* MASConstraint.h */, 251 | F515EBD81CA980E50038810A /* MASConstraint.m */, 252 | F515EBD91CA980E50038810A /* MASConstraintMaker.h */, 253 | F515EBDA1CA980E50038810A /* MASConstraintMaker.m */, 254 | F515EBDB1CA980E50038810A /* MASLayoutConstraint.h */, 255 | F515EBDC1CA980E50038810A /* MASLayoutConstraint.m */, 256 | F515EBDD1CA980E50038810A /* Masonry.h */, 257 | F515EBDE1CA980E50038810A /* MASUtilities.h */, 258 | F515EBDF1CA980E50038810A /* MASViewAttribute.h */, 259 | F515EBE01CA980E50038810A /* MASViewAttribute.m */, 260 | F515EBE11CA980E50038810A /* MASViewConstraint.h */, 261 | F515EBE21CA980E50038810A /* MASViewConstraint.m */, 262 | F515EBE31CA980E50038810A /* NSArray+MASAdditions.h */, 263 | F515EBE41CA980E50038810A /* NSArray+MASAdditions.m */, 264 | F515EBE51CA980E50038810A /* NSArray+MASShorthandAdditions.h */, 265 | F515EBE61CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.h */, 266 | F515EBE71CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.m */, 267 | F515EBE81CA980E50038810A /* View+MASAdditions.h */, 268 | F515EBE91CA980E50038810A /* View+MASAdditions.m */, 269 | F515EBEA1CA980E50038810A /* View+MASShorthandAdditions.h */, 270 | F515EBEB1CA980E50038810A /* ViewController+MASAdditions.h */, 271 | F515EBEC1CA980E50038810A /* ViewController+MASAdditions.m */, 272 | ); 273 | path = Masonry; 274 | sourceTree = ""; 275 | }; 276 | /* End PBXGroup section */ 277 | 278 | /* Begin PBXNativeTarget section */ 279 | F515EB891CA980D50038810A /* LrdAlert */ = { 280 | isa = PBXNativeTarget; 281 | buildConfigurationList = F515EBB71CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlert" */; 282 | buildPhases = ( 283 | F515EB861CA980D50038810A /* Sources */, 284 | F515EB871CA980D50038810A /* Frameworks */, 285 | F515EB881CA980D50038810A /* Resources */, 286 | ); 287 | buildRules = ( 288 | ); 289 | dependencies = ( 290 | ); 291 | name = LrdAlert; 292 | productName = LrdAlert; 293 | productReference = F515EB8A1CA980D50038810A /* LrdAlert.app */; 294 | productType = "com.apple.product-type.application"; 295 | }; 296 | F515EBA21CA980D60038810A /* LrdAlertTests */ = { 297 | isa = PBXNativeTarget; 298 | buildConfigurationList = F515EBBA1CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlertTests" */; 299 | buildPhases = ( 300 | F515EB9F1CA980D60038810A /* Sources */, 301 | F515EBA01CA980D60038810A /* Frameworks */, 302 | F515EBA11CA980D60038810A /* Resources */, 303 | ); 304 | buildRules = ( 305 | ); 306 | dependencies = ( 307 | F515EBA51CA980D60038810A /* PBXTargetDependency */, 308 | ); 309 | name = LrdAlertTests; 310 | productName = LrdAlertTests; 311 | productReference = F515EBA31CA980D60038810A /* LrdAlertTests.xctest */; 312 | productType = "com.apple.product-type.bundle.unit-test"; 313 | }; 314 | F515EBAD1CA980D60038810A /* LrdAlertUITests */ = { 315 | isa = PBXNativeTarget; 316 | buildConfigurationList = F515EBBD1CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlertUITests" */; 317 | buildPhases = ( 318 | F515EBAA1CA980D60038810A /* Sources */, 319 | F515EBAB1CA980D60038810A /* Frameworks */, 320 | F515EBAC1CA980D60038810A /* Resources */, 321 | ); 322 | buildRules = ( 323 | ); 324 | dependencies = ( 325 | F515EBB01CA980D60038810A /* PBXTargetDependency */, 326 | ); 327 | name = LrdAlertUITests; 328 | productName = LrdAlertUITests; 329 | productReference = F515EBAE1CA980D60038810A /* LrdAlertUITests.xctest */; 330 | productType = "com.apple.product-type.bundle.ui-testing"; 331 | }; 332 | /* End PBXNativeTarget section */ 333 | 334 | /* Begin PBXProject section */ 335 | F515EB821CA980D50038810A /* Project object */ = { 336 | isa = PBXProject; 337 | attributes = { 338 | LastUpgradeCheck = 0720; 339 | ORGANIZATIONNAME = "键盘上的舞者"; 340 | TargetAttributes = { 341 | F515EB891CA980D50038810A = { 342 | CreatedOnToolsVersion = 7.2.1; 343 | }; 344 | F515EBA21CA980D60038810A = { 345 | CreatedOnToolsVersion = 7.2.1; 346 | TestTargetID = F515EB891CA980D50038810A; 347 | }; 348 | F515EBAD1CA980D60038810A = { 349 | CreatedOnToolsVersion = 7.2.1; 350 | TestTargetID = F515EB891CA980D50038810A; 351 | }; 352 | }; 353 | }; 354 | buildConfigurationList = F515EB851CA980D50038810A /* Build configuration list for PBXProject "LrdAlert" */; 355 | compatibilityVersion = "Xcode 3.2"; 356 | developmentRegion = English; 357 | hasScannedForEncodings = 0; 358 | knownRegions = ( 359 | en, 360 | Base, 361 | ); 362 | mainGroup = F515EB811CA980D50038810A; 363 | productRefGroup = F515EB8B1CA980D50038810A /* Products */; 364 | projectDirPath = ""; 365 | projectRoot = ""; 366 | targets = ( 367 | F515EB891CA980D50038810A /* LrdAlert */, 368 | F515EBA21CA980D60038810A /* LrdAlertTests */, 369 | F515EBAD1CA980D60038810A /* LrdAlertUITests */, 370 | ); 371 | }; 372 | /* End PBXProject section */ 373 | 374 | /* Begin PBXResourcesBuildPhase section */ 375 | F515EB881CA980D50038810A /* Resources */ = { 376 | isa = PBXResourcesBuildPhase; 377 | buildActionMask = 2147483647; 378 | files = ( 379 | F515EBED1CA980E50038810A /* close_icon@2x.png in Resources */, 380 | F515EB9D1CA980D50038810A /* LaunchScreen.storyboard in Resources */, 381 | F515EBF21CA980E50038810A /* close_icon@2x.png in Resources */, 382 | F515EB9A1CA980D50038810A /* Assets.xcassets in Resources */, 383 | F515EB981CA980D50038810A /* Main.storyboard in Resources */, 384 | ); 385 | runOnlyForDeploymentPostprocessing = 0; 386 | }; 387 | F515EBA11CA980D60038810A /* Resources */ = { 388 | isa = PBXResourcesBuildPhase; 389 | buildActionMask = 2147483647; 390 | files = ( 391 | ); 392 | runOnlyForDeploymentPostprocessing = 0; 393 | }; 394 | F515EBAC1CA980D60038810A /* Resources */ = { 395 | isa = PBXResourcesBuildPhase; 396 | buildActionMask = 2147483647; 397 | files = ( 398 | ); 399 | runOnlyForDeploymentPostprocessing = 0; 400 | }; 401 | /* End PBXResourcesBuildPhase section */ 402 | 403 | /* Begin PBXSourcesBuildPhase section */ 404 | F515EB861CA980D50038810A /* Sources */ = { 405 | isa = PBXSourcesBuildPhase; 406 | buildActionMask = 2147483647; 407 | files = ( 408 | F515EBFE1CA980E50038810A /* View+MASAdditions.m in Sources */, 409 | F515EBEF1CA980E50038810A /* LrdDateModel.m in Sources */, 410 | F515EBF31CA980E50038810A /* LrdPasswordAlertView.m in Sources */, 411 | F515EB951CA980D50038810A /* ViewController.m in Sources */, 412 | F515EBF11CA980E50038810A /* CameraAlertView.m in Sources */, 413 | F515EB921CA980D50038810A /* AppDelegate.m in Sources */, 414 | F515EBFF1CA980E50038810A /* ViewController+MASAdditions.m in Sources */, 415 | F515EBFA1CA980E50038810A /* MASViewAttribute.m in Sources */, 416 | F515EBF61CA980E50038810A /* MASCompositeConstraint.m in Sources */, 417 | F515EBF41CA980E50038810A /* WTReParser.m in Sources */, 418 | F515EB8F1CA980D50038810A /* main.m in Sources */, 419 | F515EBF81CA980E50038810A /* MASConstraintMaker.m in Sources */, 420 | F515EBF71CA980E50038810A /* MASConstraint.m in Sources */, 421 | F515EBFD1CA980E50038810A /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 422 | F515EBF91CA980E50038810A /* MASLayoutConstraint.m in Sources */, 423 | F515EBFC1CA980E50038810A /* NSArray+MASAdditions.m in Sources */, 424 | F515EBF01CA980E50038810A /* LrdTableViewCell.m in Sources */, 425 | F515EBEE1CA980E50038810A /* LrdAlertTableView.m in Sources */, 426 | F515EBF51CA980E50038810A /* WTReTextField.m in Sources */, 427 | F515EBFB1CA980E50038810A /* MASViewConstraint.m in Sources */, 428 | ); 429 | runOnlyForDeploymentPostprocessing = 0; 430 | }; 431 | F515EB9F1CA980D60038810A /* Sources */ = { 432 | isa = PBXSourcesBuildPhase; 433 | buildActionMask = 2147483647; 434 | files = ( 435 | F515EBA81CA980D60038810A /* LrdAlertTests.m in Sources */, 436 | ); 437 | runOnlyForDeploymentPostprocessing = 0; 438 | }; 439 | F515EBAA1CA980D60038810A /* Sources */ = { 440 | isa = PBXSourcesBuildPhase; 441 | buildActionMask = 2147483647; 442 | files = ( 443 | F515EBB31CA980D60038810A /* LrdAlertUITests.m in Sources */, 444 | ); 445 | runOnlyForDeploymentPostprocessing = 0; 446 | }; 447 | /* End PBXSourcesBuildPhase section */ 448 | 449 | /* Begin PBXTargetDependency section */ 450 | F515EBA51CA980D60038810A /* PBXTargetDependency */ = { 451 | isa = PBXTargetDependency; 452 | target = F515EB891CA980D50038810A /* LrdAlert */; 453 | targetProxy = F515EBA41CA980D60038810A /* PBXContainerItemProxy */; 454 | }; 455 | F515EBB01CA980D60038810A /* PBXTargetDependency */ = { 456 | isa = PBXTargetDependency; 457 | target = F515EB891CA980D50038810A /* LrdAlert */; 458 | targetProxy = F515EBAF1CA980D60038810A /* PBXContainerItemProxy */; 459 | }; 460 | /* End PBXTargetDependency section */ 461 | 462 | /* Begin PBXVariantGroup section */ 463 | F515EB961CA980D50038810A /* Main.storyboard */ = { 464 | isa = PBXVariantGroup; 465 | children = ( 466 | F515EB971CA980D50038810A /* Base */, 467 | ); 468 | name = Main.storyboard; 469 | sourceTree = ""; 470 | }; 471 | F515EB9B1CA980D50038810A /* LaunchScreen.storyboard */ = { 472 | isa = PBXVariantGroup; 473 | children = ( 474 | F515EB9C1CA980D50038810A /* Base */, 475 | ); 476 | name = LaunchScreen.storyboard; 477 | sourceTree = ""; 478 | }; 479 | /* End PBXVariantGroup section */ 480 | 481 | /* Begin XCBuildConfiguration section */ 482 | F515EBB51CA980D60038810A /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | ALWAYS_SEARCH_USER_PATHS = NO; 486 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 487 | CLANG_CXX_LIBRARY = "libc++"; 488 | CLANG_ENABLE_MODULES = YES; 489 | CLANG_ENABLE_OBJC_ARC = YES; 490 | CLANG_WARN_BOOL_CONVERSION = YES; 491 | CLANG_WARN_CONSTANT_CONVERSION = YES; 492 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 493 | CLANG_WARN_EMPTY_BODY = YES; 494 | CLANG_WARN_ENUM_CONVERSION = YES; 495 | CLANG_WARN_INT_CONVERSION = YES; 496 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 497 | CLANG_WARN_UNREACHABLE_CODE = YES; 498 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 499 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 500 | COPY_PHASE_STRIP = NO; 501 | DEBUG_INFORMATION_FORMAT = dwarf; 502 | ENABLE_STRICT_OBJC_MSGSEND = YES; 503 | ENABLE_TESTABILITY = YES; 504 | GCC_C_LANGUAGE_STANDARD = gnu99; 505 | GCC_DYNAMIC_NO_PIC = NO; 506 | GCC_NO_COMMON_BLOCKS = YES; 507 | GCC_OPTIMIZATION_LEVEL = 0; 508 | GCC_PREPROCESSOR_DEFINITIONS = ( 509 | "DEBUG=1", 510 | "$(inherited)", 511 | ); 512 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 513 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 514 | GCC_WARN_UNDECLARED_SELECTOR = YES; 515 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 516 | GCC_WARN_UNUSED_FUNCTION = YES; 517 | GCC_WARN_UNUSED_VARIABLE = YES; 518 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 519 | MTL_ENABLE_DEBUG_INFO = YES; 520 | ONLY_ACTIVE_ARCH = YES; 521 | SDKROOT = iphoneos; 522 | TARGETED_DEVICE_FAMILY = "1,2"; 523 | }; 524 | name = Debug; 525 | }; 526 | F515EBB61CA980D60038810A /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | buildSettings = { 529 | ALWAYS_SEARCH_USER_PATHS = NO; 530 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 531 | CLANG_CXX_LIBRARY = "libc++"; 532 | CLANG_ENABLE_MODULES = YES; 533 | CLANG_ENABLE_OBJC_ARC = YES; 534 | CLANG_WARN_BOOL_CONVERSION = YES; 535 | CLANG_WARN_CONSTANT_CONVERSION = YES; 536 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 537 | CLANG_WARN_EMPTY_BODY = YES; 538 | CLANG_WARN_ENUM_CONVERSION = YES; 539 | CLANG_WARN_INT_CONVERSION = YES; 540 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 541 | CLANG_WARN_UNREACHABLE_CODE = YES; 542 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 543 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 544 | COPY_PHASE_STRIP = NO; 545 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 546 | ENABLE_NS_ASSERTIONS = NO; 547 | ENABLE_STRICT_OBJC_MSGSEND = YES; 548 | GCC_C_LANGUAGE_STANDARD = gnu99; 549 | GCC_NO_COMMON_BLOCKS = YES; 550 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 551 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 552 | GCC_WARN_UNDECLARED_SELECTOR = YES; 553 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 554 | GCC_WARN_UNUSED_FUNCTION = YES; 555 | GCC_WARN_UNUSED_VARIABLE = YES; 556 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 557 | MTL_ENABLE_DEBUG_INFO = NO; 558 | SDKROOT = iphoneos; 559 | TARGETED_DEVICE_FAMILY = "1,2"; 560 | VALIDATE_PRODUCT = YES; 561 | }; 562 | name = Release; 563 | }; 564 | F515EBB81CA980D60038810A /* Debug */ = { 565 | isa = XCBuildConfiguration; 566 | buildSettings = { 567 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 568 | INFOPLIST_FILE = LrdAlert/Info.plist; 569 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 570 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlert; 571 | PRODUCT_NAME = "$(TARGET_NAME)"; 572 | }; 573 | name = Debug; 574 | }; 575 | F515EBB91CA980D60038810A /* Release */ = { 576 | isa = XCBuildConfiguration; 577 | buildSettings = { 578 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 579 | INFOPLIST_FILE = LrdAlert/Info.plist; 580 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 581 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlert; 582 | PRODUCT_NAME = "$(TARGET_NAME)"; 583 | }; 584 | name = Release; 585 | }; 586 | F515EBBB1CA980D60038810A /* Debug */ = { 587 | isa = XCBuildConfiguration; 588 | buildSettings = { 589 | BUNDLE_LOADER = "$(TEST_HOST)"; 590 | INFOPLIST_FILE = LrdAlertTests/Info.plist; 591 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 592 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlertTests; 593 | PRODUCT_NAME = "$(TARGET_NAME)"; 594 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LrdAlert.app/LrdAlert"; 595 | }; 596 | name = Debug; 597 | }; 598 | F515EBBC1CA980D60038810A /* Release */ = { 599 | isa = XCBuildConfiguration; 600 | buildSettings = { 601 | BUNDLE_LOADER = "$(TEST_HOST)"; 602 | INFOPLIST_FILE = LrdAlertTests/Info.plist; 603 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 604 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlertTests; 605 | PRODUCT_NAME = "$(TARGET_NAME)"; 606 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LrdAlert.app/LrdAlert"; 607 | }; 608 | name = Release; 609 | }; 610 | F515EBBE1CA980D60038810A /* Debug */ = { 611 | isa = XCBuildConfiguration; 612 | buildSettings = { 613 | INFOPLIST_FILE = LrdAlertUITests/Info.plist; 614 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 615 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlertUITests; 616 | PRODUCT_NAME = "$(TARGET_NAME)"; 617 | TEST_TARGET_NAME = LrdAlert; 618 | USES_XCTRUNNER = YES; 619 | }; 620 | name = Debug; 621 | }; 622 | F515EBBF1CA980D60038810A /* Release */ = { 623 | isa = XCBuildConfiguration; 624 | buildSettings = { 625 | INFOPLIST_FILE = LrdAlertUITests/Info.plist; 626 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 627 | PRODUCT_BUNDLE_IDENTIFIER = com.lrd.LrdAlertUITests; 628 | PRODUCT_NAME = "$(TARGET_NAME)"; 629 | TEST_TARGET_NAME = LrdAlert; 630 | USES_XCTRUNNER = YES; 631 | }; 632 | name = Release; 633 | }; 634 | /* End XCBuildConfiguration section */ 635 | 636 | /* Begin XCConfigurationList section */ 637 | F515EB851CA980D50038810A /* Build configuration list for PBXProject "LrdAlert" */ = { 638 | isa = XCConfigurationList; 639 | buildConfigurations = ( 640 | F515EBB51CA980D60038810A /* Debug */, 641 | F515EBB61CA980D60038810A /* Release */, 642 | ); 643 | defaultConfigurationIsVisible = 0; 644 | defaultConfigurationName = Release; 645 | }; 646 | F515EBB71CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlert" */ = { 647 | isa = XCConfigurationList; 648 | buildConfigurations = ( 649 | F515EBB81CA980D60038810A /* Debug */, 650 | F515EBB91CA980D60038810A /* Release */, 651 | ); 652 | defaultConfigurationIsVisible = 0; 653 | }; 654 | F515EBBA1CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlertTests" */ = { 655 | isa = XCConfigurationList; 656 | buildConfigurations = ( 657 | F515EBBB1CA980D60038810A /* Debug */, 658 | F515EBBC1CA980D60038810A /* Release */, 659 | ); 660 | defaultConfigurationIsVisible = 0; 661 | }; 662 | F515EBBD1CA980D60038810A /* Build configuration list for PBXNativeTarget "LrdAlertUITests" */ = { 663 | isa = XCConfigurationList; 664 | buildConfigurations = ( 665 | F515EBBE1CA980D60038810A /* Debug */, 666 | F515EBBF1CA980D60038810A /* Release */, 667 | ); 668 | defaultConfigurationIsVisible = 0; 669 | }; 670 | /* End XCConfigurationList section */ 671 | }; 672 | rootObject = F515EB821CA980D50038810A /* Project object */; 673 | } 674 | -------------------------------------------------------------------------------- /LrdAlert.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LrdAlert.xcodeproj/xcuserdata/Up.xcuserdatad/xcschemes/LrdAlert.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /LrdAlert.xcodeproj/xcuserdata/Up.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LrdAlert.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F515EB891CA980D50038810A 16 | 17 | primary 18 | 19 | 20 | F515EBA21CA980D60038810A 21 | 22 | primary 23 | 24 | 25 | F515EBAD1CA980D60038810A 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LrdAlert/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LrdAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. 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 | -------------------------------------------------------------------------------- /LrdAlert/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LrdAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. 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 | -------------------------------------------------------------------------------- /LrdAlert/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 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LrdAlert/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 | -------------------------------------------------------------------------------- /LrdAlert/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /LrdAlert/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 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdAlertTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LrdAlertTableView.h 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LrdAlertTableView : UIView 12 | 13 | //从外面传进来的数据数组 14 | @property (nonatomic, strong) NSMutableArray *dataArray; 15 | 16 | //弹出 17 | - (void)pop; 18 | 19 | //隐藏 20 | - (void)dismiss; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdAlertTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdAlertTableView.m 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "LrdAlertTableView.h" 10 | #import "Masonry.h" 11 | #import "LrdTableViewCell.h" 12 | #import "LrdDateModel.h" 13 | 14 | #define tableViewHeight [UIScreen mainScreen].bounds.size.height - 80 -100 15 | 16 | @interface LrdAlertTableView () 17 | //背景 18 | @property (nonatomic, strong) UIView *backgroundView; 19 | 20 | @property (nonatomic, strong) UIView *contentView; 21 | //标题 22 | @property (nonatomic, strong) UILabel *title; 23 | //子标题 24 | @property (nonatomic, strong) UILabel *subTitle; 25 | //线条 26 | @property (nonatomic, strong) UILabel *line; 27 | //tableView 28 | @property (nonatomic, strong) UITableView *tableView; 29 | //关闭按钮 30 | @property (nonatomic, strong) UIButton *closeButton; 31 | 32 | 33 | @end 34 | 35 | @implementation LrdAlertTableView 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame { 38 | self = [super initWithFrame:frame]; 39 | if (self) { 40 | //初始化各种控件 41 | _backgroundView = [[UIView alloc] initWithFrame:frame]; 42 | _backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; 43 | [self addSubview:_backgroundView]; 44 | 45 | _contentView = [[UIView alloc] init]; 46 | _contentView.backgroundColor = [UIColor whiteColor]; 47 | _contentView.layer.masksToBounds = YES; 48 | _contentView.layer.cornerRadius = 5; 49 | [self addSubview:_contentView]; 50 | 51 | _title = [[UILabel alloc] init]; 52 | _title.font = [UIFont boldSystemFontOfSize:18]; 53 | _title.textAlignment = NSTextAlignmentCenter; 54 | _title.textColor = [UIColor blackColor]; 55 | _title.text = @"还款详情"; 56 | [self.contentView addSubview:_title]; 57 | 58 | _subTitle = [[UILabel alloc] init]; 59 | _subTitle.font = [UIFont systemFontOfSize:13]; 60 | _subTitle.textColor = [UIColor grayColor]; 61 | _subTitle.textAlignment = NSTextAlignmentCenter; 62 | _subTitle.text = @"每月应还本金¥50.00"; 63 | [self.contentView addSubview:_subTitle]; 64 | 65 | _line = [[UILabel alloc] init]; 66 | _line.backgroundColor = [UIColor grayColor]; 67 | [self.contentView addSubview:_line]; 68 | 69 | _closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; 70 | [_closeButton setImage:[UIImage imageNamed:@"close_icon"] forState:UIControlStateNormal]; 71 | [_closeButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; 72 | [self.contentView addSubview:_closeButton]; 73 | 74 | _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 75 | _tableView.delegate = self; 76 | _tableView.dataSource = self; 77 | _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 78 | _tableView.showsVerticalScrollIndicator = NO; 79 | [self.contentView addSubview:_tableView]; 80 | 81 | //添加布局约束 82 | [self initUI]; 83 | } 84 | return self; 85 | } 86 | 87 | - (void)initUI { 88 | [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { 89 | make.top.equalTo(self.mas_top).offset(100); 90 | make.left.equalTo(self.mas_left).offset(50); 91 | make.right.equalTo(self.mas_right).offset(-50); 92 | make.height.mas_equalTo(tableViewHeight); 93 | }]; 94 | 95 | [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) { 96 | make.top.equalTo(self.contentView.mas_top).offset(10); 97 | make.right.equalTo(self.contentView.mas_right).offset(-10); 98 | }]; 99 | 100 | [self.title mas_makeConstraints:^(MASConstraintMaker *make) { 101 | make.top.equalTo(self.contentView.mas_top).offset(25); 102 | make.left.equalTo(self.contentView.mas_left); 103 | make.right.equalTo(self.contentView.mas_right); 104 | }]; 105 | 106 | [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) { 107 | make.top.equalTo(self.title.mas_bottom).offset(20); 108 | make.left.equalTo(self.contentView.mas_left); 109 | make.right.equalTo(self.contentView.mas_right); 110 | }]; 111 | 112 | [self.line mas_makeConstraints:^(MASConstraintMaker *make) { 113 | make.top.equalTo(self.subTitle.mas_bottom).offset(20); 114 | make.left.equalTo(self.contentView.mas_left); 115 | make.right.equalTo(self.contentView.mas_right); 116 | make.height.mas_equalTo(@1); 117 | }]; 118 | 119 | [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { 120 | make.top.equalTo(self.line.mas_bottom).offset(5); 121 | make.left.equalTo(self.contentView.mas_left); 122 | make.right.equalTo(self.contentView.mas_right); 123 | make.bottom.equalTo(self.contentView.mas_bottom).offset(-5); 124 | }]; 125 | 126 | } 127 | 128 | #pragma mark pop和dismiss 129 | 130 | - (void)pop { 131 | UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; 132 | [keyWindow addSubview:self]; 133 | 134 | //动画效果入场 135 | self.contentView.transform = CGAffineTransformMakeScale(0.2, 0.2); 136 | self.contentView.alpha = 0; 137 | [UIView animateWithDuration:.35 animations:^{ 138 | self.contentView.transform = CGAffineTransformMakeScale(1.0, 1.0); 139 | self.contentView.alpha = 1; 140 | }]; 141 | } 142 | 143 | - (void)dismiss { 144 | //动画效果出场 145 | [UIView animateWithDuration:.35 animations:^{ 146 | self.contentView.transform = CGAffineTransformMakeScale(0.2, 0.2); 147 | self.contentView.alpha = 0; 148 | } completion:^(BOOL finished) { 149 | if (finished) { 150 | [self removeFromSuperview]; 151 | } 152 | }]; 153 | } 154 | 155 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 156 | UITouch *touch = [touches anyObject]; 157 | if (![touch.view isEqual:self.contentView]) { 158 | [self dismiss]; 159 | } 160 | } 161 | 162 | #pragma mark tableView的代理方法 163 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 164 | return self.dataArray.count; 165 | } 166 | 167 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 168 | static NSString *ID = @"cell"; 169 | LrdTableViewCell *cell = (LrdTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ID]; 170 | if (cell == nil) { 171 | cell = [[LrdTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; 172 | } 173 | cell.model = self.dataArray[indexPath.row]; 174 | cell.userInteractionEnabled = NO; 175 | return cell; 176 | } 177 | 178 | @end 179 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdDateModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // LrdDateModel.h 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LrdDateModel : NSObject 12 | 13 | @property (nonatomic, copy) NSString *time; 14 | 15 | @property (nonatomic, copy) NSString *price; 16 | 17 | - (instancetype)initWithTime:(NSString *)time price:(NSString *)price; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdDateModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdDateModel.m 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "LrdDateModel.h" 10 | 11 | @implementation LrdDateModel 12 | 13 | - (instancetype)initWithTime:(NSString *)time price:(NSString *)price { 14 | LrdDateModel *model = [[LrdDateModel alloc] init]; 15 | model.time = time; 16 | model.price = price; 17 | return model; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // LrdTableViewCell.h 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | @class LrdDateModel; 11 | 12 | @interface LrdTableViewCell : UITableViewCell 13 | 14 | @property (nonatomic, strong) LrdDateModel *model; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/LrdTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdTableViewCell.m 3 | // AlertTableView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "LrdTableViewCell.h" 10 | #import "LrdDateModel.h" 11 | #import "Masonry.h" 12 | 13 | @interface LrdTableViewCell () 14 | 15 | @property (nonatomic, strong) UILabel *time; 16 | @property (nonatomic, strong) UILabel *price; 17 | 18 | @end 19 | 20 | @implementation LrdTableViewCell 21 | 22 | #pragma mark 重写model的set方法 23 | 24 | - (void)setModel:(LrdDateModel *)model { 25 | _model = model; 26 | self.time.text = model.time; 27 | self.price.text = [NSString stringWithFormat:@"¥ %@", self.model.price]; 28 | } 29 | 30 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 31 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 32 | if (self) { 33 | _time = [[UILabel alloc] init]; 34 | _time.textColor = [UIColor grayColor]; 35 | _time.font = [UIFont systemFontOfSize:13]; 36 | [self.contentView addSubview:_time]; 37 | 38 | _price = [[UILabel alloc] init]; 39 | _price.textColor = [UIColor blackColor]; 40 | _price.font = [UIFont boldSystemFontOfSize:16]; 41 | [self.contentView addSubview:_price]; 42 | 43 | //设置约束 44 | [_time mas_makeConstraints:^(MASConstraintMaker *make) { 45 | make.left.equalTo(self.contentView.mas_left).offset(30); 46 | make.top.equalTo(self.contentView.mas_top).offset(10); 47 | }]; 48 | 49 | [_price mas_makeConstraints:^(MASConstraintMaker *make) { 50 | make.right.equalTo(self.contentView.mas_right).offset(-40); 51 | make.top.equalTo(self.contentView.mas_top).offset(10); 52 | }]; 53 | 54 | } 55 | return self; 56 | } 57 | 58 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 59 | [super setSelected:selected animated:animated]; 60 | 61 | // Configure the view for the selected state 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /LrdAlert/LrdAlertView/close_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmallMonster77/LrdAlertView/af52406d574bc0d74e0d12b6067e360dd072d1ac/LrdAlert/LrdAlertView/close_icon@2x.png -------------------------------------------------------------------------------- /LrdAlert/LrdCameraAlertView/CameraAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CameraAlertView.h 3 | // CameraAlertView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, LrdAlertButtonType) { 12 | LrdAlertButtonTypeCamera = 0, 13 | LrdAlertButtonTypeAlbum, 14 | LrdAlertButtonTypeCancel 15 | }; 16 | 17 | //代理 18 | @protocol LrdCameraAlertDelegate 19 | 20 | @optional 21 | - (void)buttonClickedWithType:(LrdAlertButtonType)type; 22 | 23 | @end 24 | 25 | @interface CameraAlertView : UIView 26 | 27 | @property (nonatomic, weak) id delegate; 28 | 29 | //弹出 30 | - (void)pop; 31 | //消失 32 | - (void)dismiss; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /LrdAlert/LrdCameraAlertView/CameraAlertView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CameraAlertView.m 3 | // CameraAlertView 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "CameraAlertView.h" 10 | #import "Masonry.h" 11 | 12 | @interface CameraAlertView () 13 | 14 | //背景 15 | @property (nonatomic, strong) UIView *backgroundView; 16 | //容器 17 | @property (nonatomic, strong) UIView *contentView; 18 | //三个按钮 19 | @property (nonatomic, strong) UIButton *cameraButton; 20 | @property (nonatomic, strong) UIButton *albumButton; 21 | @property (nonatomic, strong) UIButton *cancelButton; 22 | 23 | @end 24 | 25 | @implementation CameraAlertView 26 | 27 | - (instancetype)initWithFrame:(CGRect)frame { 28 | if (self = [super initWithFrame:frame]) { 29 | //初始化各种子控件 30 | _backgroundView = [[UIView alloc] initWithFrame:frame]; 31 | _backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; 32 | [self addSubview:_backgroundView]; 33 | 34 | _contentView = [[UIView alloc] init]; 35 | _contentView.backgroundColor = [UIColor whiteColor]; 36 | [self addSubview:_contentView]; 37 | 38 | _cameraButton = [UIButton buttonWithType:UIButtonTypeCustom]; 39 | [_cameraButton setTitle:@"相机" forState:UIControlStateNormal]; 40 | [_cameraButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 41 | [_cameraButton setBackgroundColor:[UIColor orangeColor]]; 42 | _cameraButton.layer.cornerRadius = 5; 43 | _cameraButton.tag = LrdAlertButtonTypeCamera; 44 | [_cameraButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 45 | [_contentView addSubview:_cameraButton]; 46 | 47 | _albumButton = [UIButton buttonWithType:UIButtonTypeCustom]; 48 | [_albumButton setTitle:@"从相册选择" forState:UIControlStateNormal]; 49 | [_albumButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 50 | [_albumButton setBackgroundColor:[UIColor whiteColor]]; 51 | _albumButton.layer.borderWidth = 1; 52 | _albumButton.layer.borderColor = [UIColor grayColor].CGColor; 53 | _albumButton.layer.cornerRadius = 5; 54 | _albumButton.tag = LrdAlertButtonTypeAlbum; 55 | [_albumButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 56 | [_contentView addSubview:_albumButton]; 57 | 58 | _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; 59 | [_cancelButton setTitle:@"取消" forState:UIControlStateNormal]; 60 | [_cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 61 | [_cancelButton setBackgroundColor:[UIColor grayColor]]; 62 | _cancelButton.layer.cornerRadius = 5; 63 | _cancelButton.tag = LrdAlertButtonTypeCancel; 64 | [_cancelButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 65 | [_contentView addSubview:_cancelButton]; 66 | 67 | //添加布局 68 | [self initUI]; 69 | } 70 | return self; 71 | } 72 | 73 | #pragma mark 初始化UI 74 | - (void)initUI { 75 | [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { 76 | make.top.equalTo(self.mas_bottom); 77 | make.left.equalTo(self.mas_left); 78 | make.right.equalTo(self.mas_right); 79 | make.height.mas_equalTo(@200); 80 | }]; 81 | 82 | [self.cameraButton mas_makeConstraints:^(MASConstraintMaker *make) { 83 | make.top.equalTo(self.contentView.mas_top).offset(30); 84 | make.left.equalTo(self.contentView.mas_left).offset(40); 85 | make.right.equalTo(self.contentView.mas_right).offset(-40); 86 | }]; 87 | 88 | [self.albumButton mas_makeConstraints:^(MASConstraintMaker *make) { 89 | make.top.equalTo(self.cameraButton.mas_bottom).offset(15); 90 | make.left.equalTo(self.contentView.mas_left).offset(40); 91 | make.right.equalTo(self.contentView.mas_right).offset(-40); 92 | }]; 93 | 94 | [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) { 95 | make.top.equalTo(self.albumButton.mas_bottom).offset(15); 96 | make.left.equalTo(self.contentView.mas_left).offset(40); 97 | make.right.equalTo(self.contentView.mas_right).offset(-40); 98 | }]; 99 | 100 | } 101 | 102 | #pragma mark 方法实现 103 | 104 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 105 | UITouch *touch = [touches anyObject]; 106 | if (![touch.view isEqual:self.contentView]) { 107 | [self dismiss]; 108 | } 109 | } 110 | 111 | - (void)buttonClicked:(UIButton *)button { 112 | if ([_delegate respondsToSelector:@selector(buttonClickedWithType:)]) { 113 | [_delegate buttonClickedWithType:button.tag]; 114 | } 115 | } 116 | 117 | - (void)pop { 118 | UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; 119 | [keyWindow addSubview:self]; 120 | [UIView animateWithDuration:.35 animations:^{ 121 | self.contentView.transform = CGAffineTransformMakeTranslation(0, -200); 122 | }]; 123 | } 124 | 125 | - (void)dismiss { 126 | [UIView animateWithDuration:.35 animations:^{ 127 | self.contentView.transform = CGAffineTransformIdentity; 128 | } completion:^(BOOL finished) { 129 | if (finished) { 130 | [self removeFromSuperview]; 131 | } 132 | }]; 133 | } 134 | 135 | @end 136 | -------------------------------------------------------------------------------- /LrdAlert/LrdPasswordAlertView/LrdPasswordAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LrdPasswordAlertView.h 3 | // PasswordAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WTReTextField.h" 11 | 12 | typedef void (^successBlock)(NSString *text); 13 | 14 | @interface LrdPasswordAlertView : UIView 15 | 16 | //关闭或者密码输入完成时候调用的block 17 | @property (nonatomic, strong) successBlock block; 18 | 19 | //弹出 20 | - (void)pop; 21 | 22 | //关闭 23 | - (void)dissmiss; 24 | 25 | @end 26 | 27 | @interface LrdTextField : WTReTextField 28 | 29 | 30 | 31 | @end -------------------------------------------------------------------------------- /LrdAlert/LrdPasswordAlertView/LrdPasswordAlertView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdPasswordAlertView.m 3 | // PasswordAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "LrdPasswordAlertView.h" 10 | #import "Masonry.h" 11 | 12 | #define kPasswordLength 6 13 | //textField中的竖线 14 | #define kLineTag 1000 15 | //textFiled中的星号显示 16 | #define kDotTag 3000 17 | 18 | #define textFieldWidth [UIScreen mainScreen].bounds.size.width - 50 * 2 - 10 * 2 19 | #define textFieldHeight 35 20 | 21 | @interface LrdPasswordAlertView () 22 | 23 | //背景 24 | @property (nonatomic, strong) UIView *backgroundView; 25 | //线条 26 | @property (nonatomic, strong) UILabel *lineLabel; 27 | //标题 28 | @property (nonatomic, strong) UILabel *titleLabel; 29 | //密码框 30 | @property (nonatomic, strong) LrdTextField *inputTextFiled; 31 | //中间的View 32 | @property (nonatomic, strong) UIView *centerView; 33 | //关闭按钮 34 | @property (nonatomic, strong) UIButton *closeBuuton; 35 | 36 | @end 37 | 38 | 39 | @implementation LrdPasswordAlertView 40 | 41 | //重写 init 方法 42 | - (instancetype)initWithFrame:(CGRect)frame { 43 | self = [super initWithFrame:frame]; 44 | if (self) { 45 | //后面黑色背景 46 | self.backgroundView = [[UIView alloc] initWithFrame:frame]; 47 | self.backgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; 48 | [self addSubview:self.backgroundView]; 49 | 50 | //中间的view 51 | self.centerView = [[UIView alloc] init]; 52 | self.centerView.backgroundColor = [UIColor whiteColor]; 53 | self.centerView.layer.masksToBounds = YES; 54 | self.centerView.layer.cornerRadius = 5; 55 | [self addSubview:self.centerView]; 56 | 57 | //初始化各种子控件 58 | self.titleLabel = [[UILabel alloc] init]; 59 | self.titleLabel.text = @"请输入交易密码"; 60 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 61 | self.titleLabel.font = [UIFont boldSystemFontOfSize:17]; 62 | self.titleLabel.textColor = [UIColor blackColor]; 63 | [self.centerView addSubview:self.titleLabel]; 64 | 65 | self.lineLabel = [[UILabel alloc] init]; 66 | self.lineLabel.backgroundColor = [UIColor grayColor]; 67 | [self.centerView addSubview:self.lineLabel]; 68 | 69 | self.inputTextFiled = [[LrdTextField alloc] init]; 70 | self.inputTextFiled.backgroundColor = [UIColor whiteColor]; 71 | self.inputTextFiled.layer.masksToBounds = YES; 72 | self.inputTextFiled.layer.borderColor = [UIColor grayColor].CGColor; 73 | self.inputTextFiled.layer.borderWidth = 1; 74 | self.inputTextFiled.layer.cornerRadius = 5; 75 | self.inputTextFiled.secureTextEntry = YES; 76 | self.inputTextFiled.delegate = self; 77 | self.inputTextFiled.tintColor = [UIColor clearColor];//看不到光标 78 | self.inputTextFiled.textColor = [UIColor clearColor];//看不到输入内容 79 | self.inputTextFiled.font = [UIFont systemFontOfSize:30]; 80 | self.inputTextFiled.keyboardType = UIKeyboardTypeNumberPad; 81 | self.inputTextFiled.pattern = [NSString stringWithFormat:@"^\\d{%li}$",(long)kPasswordLength - 1]; 82 | [self.inputTextFiled addTarget:self action:@selector(textFiledEdingChanged) forControlEvents:UIControlEventEditingChanged]; 83 | [self.centerView addSubview:self.inputTextFiled]; 84 | 85 | //关闭按钮 86 | self.closeBuuton = [UIButton buttonWithType:UIButtonTypeCustom]; 87 | [self.closeBuuton setImage:[UIImage imageNamed:@"close_icon"] forState:UIControlStateNormal]; 88 | [self.closeBuuton addTarget:self action:@selector(closeWindow) forControlEvents:UIControlEventTouchUpInside]; 89 | [self.centerView addSubview:self.closeBuuton]; 90 | 91 | [self setUI]; 92 | 93 | } 94 | return self; 95 | } 96 | 97 | - (void)setUI { 98 | [self.centerView mas_makeConstraints:^(MASConstraintMaker *make) { 99 | make.top.equalTo(self.mas_top).offset(150); 100 | make.left.equalTo(self.mas_left).offset(50); 101 | make.right.equalTo(self.mas_right).offset(-50); 102 | make.height.equalTo(@160); 103 | }]; 104 | 105 | [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { 106 | make.top.equalTo(self.centerView.mas_top).offset(30); 107 | make.left.equalTo(self.centerView.mas_left); 108 | make.right.equalTo(self.centerView.mas_right); 109 | }]; 110 | 111 | [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) { 112 | make.height.equalTo(@1); 113 | make.left.equalTo(self.centerView.mas_left).offset(15); 114 | make.right.equalTo(self.centerView.mas_right).offset(-15); 115 | make.top.equalTo(self.titleLabel.mas_bottom).offset(10); 116 | }]; 117 | 118 | [self.inputTextFiled mas_makeConstraints:^(MASConstraintMaker *make) { 119 | make.top.equalTo(self.lineLabel.mas_bottom).offset(20); 120 | make.left.equalTo(self.centerView.mas_left).offset(10); 121 | make.right.equalTo(self.centerView.mas_right).offset(-10); 122 | make.height.mas_equalTo(@35); 123 | }]; 124 | [self textFieldAddSubview]; 125 | 126 | [self.closeBuuton mas_makeConstraints:^(MASConstraintMaker *make) { 127 | make.top.equalTo(self.centerView.mas_top).offset(5); 128 | make.left.equalTo(self.centerView.mas_left).offset(5); 129 | }]; 130 | } 131 | 132 | #pragma mark 监听textField的值改变事件 133 | - (void)textFiledEdingChanged { 134 | NSInteger length = self.inputTextFiled.text.length; 135 | NSLog(@"%ld", length); 136 | if (length == kPasswordLength) { 137 | [self dissmiss]; 138 | } 139 | for(NSInteger i=0;i *)touches withEvent:(UIEvent *)event { 179 | UITouch *touch = [touches anyObject]; 180 | if (![touch.view isEqual:self.centerView]) { 181 | [self dissmiss]; 182 | } 183 | } 184 | 185 | - (void) closeWindow { 186 | [self dissmiss]; 187 | } 188 | 189 | //添加竖线和星号 190 | - (void)textFieldAddSubview { 191 | CGFloat perWidth = (textFieldWidth - kPasswordLength + 1)*1.0/kPasswordLength; 192 | for(NSInteger i=0;i 21 | 22 | @class WTReGroup; 23 | 24 | @interface WTReParser : NSObject 25 | { 26 | NSString *_pattern; 27 | BOOL _ignoreCase; 28 | WTReGroup *_node; 29 | BOOL _finished; 30 | NSRegularExpression *_exactQuantifierRegex; 31 | NSRegularExpression *_rangeQuantifierRegex; 32 | } 33 | 34 | - (id)initWithPattern:(NSString*)pattern; 35 | - (id)initWithPattern:(NSString*)pattern ignoreCase:(BOOL)ignoreCase; 36 | - (NSString*)reformatString:(NSString*)input; 37 | 38 | @property (readonly, nonatomic) NSString *pattern; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LrdAlert/LrdPasswordAlertView/WTReTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // WTReTextField.h 3 | // WTReTextField 4 | // 5 | // Created by Alex Skalozub on 5/5/13. 6 | // Copyright (c) 2013 Alex Skalozub. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 17 | // IN THE SOFTWARE. 18 | // 19 | 20 | #import 21 | 22 | @class WTReParser; 23 | 24 | @interface WTReTextField : UITextField 25 | { 26 | NSString *_lastAcceptedValue; 27 | WTReParser *_parser; 28 | } 29 | 30 | @property (strong, nonatomic) NSString *pattern; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /LrdAlert/LrdPasswordAlertView/WTReTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // WTReTextField.m 3 | // WTReTextField 4 | // 5 | // Created by Alex Skalozub on 5/5/13. 6 | // Copyright (c) 2013 Alex Skalozub. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 17 | // IN THE SOFTWARE. 18 | // 19 | 20 | #import "WTReTextField.h" 21 | #import "WTReParser.h" 22 | 23 | @implementation WTReTextField 24 | 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) 29 | { 30 | _lastAcceptedValue = nil; 31 | _parser = nil; 32 | [self addTarget:self action:@selector(formatInput:) forControlEvents:UIControlEventEditingChanged]; 33 | } 34 | return self; 35 | } 36 | 37 | - (id)initWithCoder:(NSCoder *)aDecoder 38 | { 39 | self = [super initWithCoder:aDecoder]; 40 | if (self) 41 | { 42 | _lastAcceptedValue = nil; 43 | _parser = nil; 44 | [self addTarget:self action:@selector(formatInput:) forControlEvents:UIControlEventEditingChanged]; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)dealloc 50 | { 51 | _lastAcceptedValue = nil; 52 | _parser = nil; 53 | [self removeTarget:self action:@selector(formatInput:) forControlEvents:UIControlEventEditingChanged]; 54 | } 55 | 56 | - (void)setPattern:(NSString *)pattern 57 | { 58 | if (pattern == nil || [pattern isEqualToString:@""]) 59 | _parser = nil; 60 | else 61 | _parser = [[WTReParser alloc] initWithPattern:pattern]; 62 | } 63 | 64 | - (NSString*)pattern 65 | { 66 | return _parser.pattern; 67 | } 68 | 69 | - (void)formatInput:(UITextField *)textField 70 | { 71 | if (_parser == nil) return; 72 | 73 | __block WTReParser *localParser = _parser; 74 | 75 | dispatch_async(dispatch_get_main_queue(), ^{ 76 | NSString *formatted = [localParser reformatString:textField.text]; 77 | if (formatted == nil) 78 | formatted = _lastAcceptedValue; 79 | else 80 | _lastAcceptedValue = formatted; 81 | NSString *newText = formatted; 82 | if (![textField.text isEqualToString:newText]) { 83 | textField.text = formatted; 84 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 85 | } 86 | }); 87 | } 88 | 89 | //lumin添加 90 | -(void)setText:(NSString *)text 91 | { 92 | [super setText:text]; 93 | [self formatInput:self]; 94 | } 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /LrdAlert/LrdPasswordAlertView/close_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmallMonster77/LrdAlertView/af52406d574bc0d74e0d12b6067e360dd072d1ac/LrdAlert/LrdPasswordAlertView/close_icon@2x.png -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if TARGET_OS_IPHONE 131 | 132 | - (MASConstraint *)leftMargin; 133 | - (MASConstraint *)rightMargin; 134 | - (MASConstraint *)topMargin; 135 | - (MASConstraint *)bottomMargin; 136 | - (MASConstraint *)leadingMargin; 137 | - (MASConstraint *)trailingMargin; 138 | - (MASConstraint *)centerXWithinMargins; 139 | - (MASConstraint *)centerYWithinMargins; 140 | 141 | #endif 142 | 143 | 144 | /** 145 | * Sets the constraint debug name 146 | */ 147 | - (MASConstraint * (^)(id key))key; 148 | 149 | // NSLayoutConstraint constant Setters 150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 156 | */ 157 | - (void)setInsets:(MASEdgeInsets)insets; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 163 | */ 164 | - (void)setSizeOffset:(CGSize)sizeOffset; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 170 | */ 171 | - (void)setCenterOffset:(CGPoint)centerOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant 175 | */ 176 | - (void)setOffset:(CGFloat)offset; 177 | 178 | 179 | // NSLayoutConstraint Installation support 180 | 181 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 182 | /** 183 | * Whether or not to go through the animator proxy when modifying the constraint 184 | */ 185 | @property (nonatomic, copy, readonly) MASConstraint *animator; 186 | #endif 187 | 188 | /** 189 | * Activates an NSLayoutConstraint if it's supported by an OS. 190 | * Invokes install otherwise. 191 | */ 192 | - (void)activate; 193 | 194 | /** 195 | * Deactivates previously installed/activated NSLayoutConstraint. 196 | */ 197 | - (void)deactivate; 198 | 199 | /** 200 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 201 | */ 202 | - (void)install; 203 | 204 | /** 205 | * Removes previously installed NSLayoutConstraint 206 | */ 207 | - (void)uninstall; 208 | 209 | @end 210 | 211 | 212 | /** 213 | * Convenience auto-boxing macros for MASConstraint methods. 214 | * 215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 216 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 217 | */ 218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 221 | 222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 223 | 224 | 225 | #ifdef MAS_SHORTHAND_GLOBALS 226 | 227 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 230 | 231 | #define offset(...) mas_offset(__VA_ARGS__) 232 | 233 | #endif 234 | 235 | 236 | @interface MASConstraint (AutoboxingSupport) 237 | 238 | /** 239 | * Aliases to corresponding relation methods (for shorthand macros) 240 | * Also needed to aid autocompletion 241 | */ 242 | - (MASConstraint * (^)(id attr))mas_equalTo; 243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 245 | 246 | /** 247 | * A dummy method to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id offset))mas_offset; 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if TARGET_OS_IPHONE 212 | 213 | - (MASConstraint *)leftMargin { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 215 | } 216 | 217 | - (MASConstraint *)rightMargin { 218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 219 | } 220 | 221 | - (MASConstraint *)topMargin { 222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 223 | } 224 | 225 | - (MASConstraint *)bottomMargin { 226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 227 | } 228 | 229 | - (MASConstraint *)leadingMargin { 230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 231 | } 232 | 233 | - (MASConstraint *)trailingMargin { 234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 235 | } 236 | 237 | - (MASConstraint *)centerXWithinMargins { 238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 239 | } 240 | 241 | - (MASConstraint *)centerYWithinMargins { 242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 243 | } 244 | 245 | #endif 246 | 247 | #pragma mark - Abstract 248 | 249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 250 | 251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 252 | 253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 254 | 255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 256 | 257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 258 | 259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 260 | 261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 262 | 263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 264 | 265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 266 | 267 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 268 | 269 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 270 | 271 | #endif 272 | 273 | - (void)activate { MASMethodNotImplemented(); } 274 | 275 | - (void)deactivate { MASMethodNotImplemented(); } 276 | 277 | - (void)install { MASMethodNotImplemented(); } 278 | 279 | - (void)uninstall { MASMethodNotImplemented(); } 280 | 281 | @end 282 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASConstraintMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraintMaker.h" 10 | #import "MASViewConstraint.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASConstraint+Private.h" 13 | #import "MASViewAttribute.h" 14 | #import "View+MASAdditions.h" 15 | 16 | @interface MASConstraintMaker () 17 | 18 | @property (nonatomic, weak) MAS_VIEW *view; 19 | @property (nonatomic, strong) NSMutableArray *constraints; 20 | 21 | @end 22 | 23 | @implementation MASConstraintMaker 24 | 25 | - (id)initWithView:(MAS_VIEW *)view { 26 | self = [super init]; 27 | if (!self) return nil; 28 | 29 | self.view = view; 30 | self.constraints = NSMutableArray.new; 31 | 32 | return self; 33 | } 34 | 35 | - (NSArray *)install { 36 | if (self.removeExisting) { 37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view]; 38 | for (MASConstraint *constraint in installedConstraints) { 39 | [constraint uninstall]; 40 | } 41 | } 42 | NSArray *constraints = self.constraints.copy; 43 | for (MASConstraint *constraint in constraints) { 44 | constraint.updateExisting = self.updateExisting; 45 | [constraint install]; 46 | } 47 | [self.constraints removeAllObjects]; 48 | return constraints; 49 | } 50 | 51 | #pragma mark - MASConstraintDelegate 52 | 53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 54 | NSUInteger index = [self.constraints indexOfObject:constraint]; 55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint]; 57 | } 58 | 59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute]; 61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute]; 62 | if ([constraint isKindOfClass:MASViewConstraint.class]) { 63 | //replace with composite constraint 64 | NSArray *children = @[constraint, newConstraint]; 65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 66 | compositeConstraint.delegate = self; 67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint]; 68 | return compositeConstraint; 69 | } 70 | if (!constraint) { 71 | newConstraint.delegate = self; 72 | [self.constraints addObject:newConstraint]; 73 | } 74 | return newConstraint; 75 | } 76 | 77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs { 78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading 79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX 80 | | MASAttributeCenterY | MASAttributeBaseline 81 | #if TARGET_OS_IPHONE 82 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin 83 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins 84 | | MASAttributeCenterYWithinMargins 85 | #endif 86 | ); 87 | 88 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)"); 89 | 90 | NSMutableArray *attributes = [NSMutableArray array]; 91 | 92 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left]; 93 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right]; 94 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top]; 95 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom]; 96 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading]; 97 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing]; 98 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width]; 99 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height]; 100 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX]; 101 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY]; 102 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline]; 103 | 104 | #if TARGET_OS_IPHONE 105 | 106 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin]; 107 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin]; 108 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin]; 109 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin]; 110 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin]; 111 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin]; 112 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins]; 113 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins]; 114 | 115 | #endif 116 | 117 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count]; 118 | 119 | for (MASViewAttribute *a in attributes) { 120 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]]; 121 | } 122 | 123 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 124 | constraint.delegate = self; 125 | [self.constraints addObject:constraint]; 126 | return constraint; 127 | } 128 | 129 | #pragma mark - standard Attributes 130 | 131 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 132 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute]; 133 | } 134 | 135 | - (MASConstraint *)left { 136 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 137 | } 138 | 139 | - (MASConstraint *)top { 140 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 141 | } 142 | 143 | - (MASConstraint *)right { 144 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 145 | } 146 | 147 | - (MASConstraint *)bottom { 148 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 149 | } 150 | 151 | - (MASConstraint *)leading { 152 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 153 | } 154 | 155 | - (MASConstraint *)trailing { 156 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 157 | } 158 | 159 | - (MASConstraint *)width { 160 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 161 | } 162 | 163 | - (MASConstraint *)height { 164 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 165 | } 166 | 167 | - (MASConstraint *)centerX { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 169 | } 170 | 171 | - (MASConstraint *)centerY { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 173 | } 174 | 175 | - (MASConstraint *)baseline { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 177 | } 178 | 179 | - (MASConstraint *(^)(MASAttribute))attributes { 180 | return ^(MASAttribute attrs){ 181 | return [self addConstraintWithAttributes:attrs]; 182 | }; 183 | } 184 | 185 | #if TARGET_OS_IPHONE 186 | 187 | - (MASConstraint *)leftMargin { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 189 | } 190 | 191 | - (MASConstraint *)rightMargin { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 193 | } 194 | 195 | - (MASConstraint *)topMargin { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 197 | } 198 | 199 | - (MASConstraint *)bottomMargin { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 201 | } 202 | 203 | - (MASConstraint *)leadingMargin { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 205 | } 206 | 207 | - (MASConstraint *)trailingMargin { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 209 | } 210 | 211 | - (MASConstraint *)centerXWithinMargins { 212 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 213 | } 214 | 215 | - (MASConstraint *)centerYWithinMargins { 216 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 217 | } 218 | 219 | #endif 220 | 221 | 222 | #pragma mark - composite Attributes 223 | 224 | - (MASConstraint *)edges { 225 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom]; 226 | } 227 | 228 | - (MASConstraint *)size { 229 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight]; 230 | } 231 | 232 | - (MASConstraint *)center { 233 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY]; 234 | } 235 | 236 | #pragma mark - grouping 237 | 238 | - (MASConstraint *(^)(dispatch_block_t group))group { 239 | return ^id(dispatch_block_t group) { 240 | NSInteger previousCount = self.constraints.count; 241 | group(); 242 | 243 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)]; 244 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 245 | constraint.delegate = self; 246 | return constraint; 247 | }; 248 | } 249 | 250 | @end 251 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MAS_VIEW_CONTROLLER UIViewController 16 | #define MASEdgeInsets UIEdgeInsets 17 | 18 | typedef UILayoutPriority MASLayoutPriority; 19 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 23 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 24 | 25 | #elif TARGET_OS_MAC 26 | 27 | #import 28 | #define MAS_VIEW NSView 29 | #define MASEdgeInsets NSEdgeInsets 30 | 31 | typedef NSLayoutPriority MASLayoutPriority; 32 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 33 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 34 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 36 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 37 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 38 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 39 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 40 | 41 | #endif 42 | 43 | /** 44 | * Allows you to attach keys to objects matching the variable names passed. 45 | * 46 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 47 | * 48 | * is equivalent to: 49 | * 50 | * MASAttachKeys(view1, view2); 51 | */ 52 | #define MASAttachKeys(...) \ 53 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 54 | for (id key in keyPairs.allKeys) { \ 55 | id obj = keyPairs[key]; \ 56 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 57 | @"Cannot attach mas_key to %@", obj); \ 58 | [obj setMas_key:key]; \ 59 | } 60 | 61 | /** 62 | * Used to create object hashes 63 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 64 | */ 65 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 66 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 67 | 68 | /** 69 | * Given a scalar or struct value, wraps it in NSValue 70 | * Based on EXPObjectify: https://github.com/specta/expecta 71 | */ 72 | static inline id _MASBoxValue(const char *type, ...) { 73 | va_list v; 74 | va_start(v, type); 75 | id obj = nil; 76 | if (strcmp(type, @encode(id)) == 0) { 77 | id actual = va_arg(v, id); 78 | obj = actual; 79 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 80 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 81 | obj = [NSValue value:&actual withObjCType:type]; 82 | } else if (strcmp(type, @encode(CGSize)) == 0) { 83 | CGSize actual = (CGSize)va_arg(v, CGSize); 84 | obj = [NSValue value:&actual withObjCType:type]; 85 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 86 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 87 | obj = [NSValue value:&actual withObjCType:type]; 88 | } else if (strcmp(type, @encode(double)) == 0) { 89 | double actual = (double)va_arg(v, double); 90 | obj = [NSNumber numberWithDouble:actual]; 91 | } else if (strcmp(type, @encode(float)) == 0) { 92 | float actual = (float)va_arg(v, double); 93 | obj = [NSNumber numberWithFloat:actual]; 94 | } else if (strcmp(type, @encode(int)) == 0) { 95 | int actual = (int)va_arg(v, int); 96 | obj = [NSNumber numberWithInt:actual]; 97 | } else if (strcmp(type, @encode(long)) == 0) { 98 | long actual = (long)va_arg(v, long); 99 | obj = [NSNumber numberWithLong:actual]; 100 | } else if (strcmp(type, @encode(long long)) == 0) { 101 | long long actual = (long long)va_arg(v, long long); 102 | obj = [NSNumber numberWithLongLong:actual]; 103 | } else if (strcmp(type, @encode(short)) == 0) { 104 | short actual = (short)va_arg(v, int); 105 | obj = [NSNumber numberWithShort:actual]; 106 | } else if (strcmp(type, @encode(char)) == 0) { 107 | char actual = (char)va_arg(v, int); 108 | obj = [NSNumber numberWithChar:actual]; 109 | } else if (strcmp(type, @encode(bool)) == 0) { 110 | bool actual = (bool)va_arg(v, int); 111 | obj = [NSNumber numberWithBool:actual]; 112 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 113 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 114 | obj = [NSNumber numberWithUnsignedChar:actual]; 115 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 116 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 117 | obj = [NSNumber numberWithUnsignedInt:actual]; 118 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 119 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 120 | obj = [NSNumber numberWithUnsignedLong:actual]; 121 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 122 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 123 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 124 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 125 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 126 | obj = [NSNumber numberWithUnsignedShort:actual]; 127 | } 128 | va_end(v); 129 | return obj; 130 | } 131 | 132 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 133 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/MASViewConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | #import "MASCompositeConstraint.h" 12 | #import "MASLayoutConstraint.h" 13 | #import "View+MASAdditions.h" 14 | #import 15 | 16 | @interface MAS_VIEW (MASConstraints) 17 | 18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints; 19 | 20 | @end 21 | 22 | @implementation MAS_VIEW (MASConstraints) 23 | 24 | static char kInstalledConstraintsKey; 25 | 26 | - (NSMutableSet *)mas_installedConstraints { 27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey); 28 | if (!constraints) { 29 | constraints = [NSMutableSet set]; 30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 31 | } 32 | return constraints; 33 | } 34 | 35 | @end 36 | 37 | 38 | @interface MASViewConstraint () 39 | 40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute; 41 | @property (nonatomic, weak) MAS_VIEW *installedView; 42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint; 43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation; 44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority; 45 | @property (nonatomic, assign) CGFloat layoutMultiplier; 46 | @property (nonatomic, assign) CGFloat layoutConstant; 47 | @property (nonatomic, assign) BOOL hasLayoutRelation; 48 | @property (nonatomic, strong) id mas_key; 49 | @property (nonatomic, assign) BOOL useAnimator; 50 | 51 | @end 52 | 53 | @implementation MASViewConstraint 54 | 55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute { 56 | self = [super init]; 57 | if (!self) return nil; 58 | 59 | _firstViewAttribute = firstViewAttribute; 60 | self.layoutPriority = MASLayoutPriorityRequired; 61 | self.layoutMultiplier = 1; 62 | 63 | return self; 64 | } 65 | 66 | #pragma mark - NSCoping 67 | 68 | - (id)copyWithZone:(NSZone __unused *)zone { 69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute]; 70 | constraint.layoutConstant = self.layoutConstant; 71 | constraint.layoutRelation = self.layoutRelation; 72 | constraint.layoutPriority = self.layoutPriority; 73 | constraint.layoutMultiplier = self.layoutMultiplier; 74 | constraint.delegate = self.delegate; 75 | return constraint; 76 | } 77 | 78 | #pragma mark - Public 79 | 80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view { 81 | return [view.mas_installedConstraints allObjects]; 82 | } 83 | 84 | #pragma mark - Private 85 | 86 | - (void)setLayoutConstant:(CGFloat)layoutConstant { 87 | _layoutConstant = layoutConstant; 88 | 89 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 90 | if (self.useAnimator) { 91 | [self.layoutConstraint.animator setConstant:layoutConstant]; 92 | } else { 93 | self.layoutConstraint.constant = layoutConstant; 94 | } 95 | #else 96 | self.layoutConstraint.constant = layoutConstant; 97 | #endif 98 | } 99 | 100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 101 | _layoutRelation = layoutRelation; 102 | self.hasLayoutRelation = YES; 103 | } 104 | 105 | - (BOOL)supportsActiveProperty { 106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)]; 107 | } 108 | 109 | - (BOOL)isActive { 110 | BOOL active = YES; 111 | if ([self supportsActiveProperty]) { 112 | active = [self.layoutConstraint isActive]; 113 | } 114 | 115 | return active; 116 | } 117 | 118 | - (BOOL)hasBeenInstalled { 119 | return (self.layoutConstraint != nil) && [self isActive]; 120 | } 121 | 122 | - (void)setSecondViewAttribute:(id)secondViewAttribute { 123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) { 124 | [self setLayoutConstantWithValue:secondViewAttribute]; 125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) { 126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute]; 127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) { 128 | _secondViewAttribute = secondViewAttribute; 129 | } else { 130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute); 131 | } 132 | } 133 | 134 | #pragma mark - NSLayoutConstraint multiplier proxies 135 | 136 | - (MASConstraint * (^)(CGFloat))multipliedBy { 137 | return ^id(CGFloat multiplier) { 138 | NSAssert(!self.hasBeenInstalled, 139 | @"Cannot modify constraint multiplier after it has been installed"); 140 | 141 | self.layoutMultiplier = multiplier; 142 | return self; 143 | }; 144 | } 145 | 146 | 147 | - (MASConstraint * (^)(CGFloat))dividedBy { 148 | return ^id(CGFloat divider) { 149 | NSAssert(!self.hasBeenInstalled, 150 | @"Cannot modify constraint multiplier after it has been installed"); 151 | 152 | self.layoutMultiplier = 1.0/divider; 153 | return self; 154 | }; 155 | } 156 | 157 | #pragma mark - MASLayoutPriority proxy 158 | 159 | - (MASConstraint * (^)(MASLayoutPriority))priority { 160 | return ^id(MASLayoutPriority priority) { 161 | NSAssert(!self.hasBeenInstalled, 162 | @"Cannot modify constraint priority after it has been installed"); 163 | 164 | self.layoutPriority = priority; 165 | return self; 166 | }; 167 | } 168 | 169 | #pragma mark - NSLayoutRelation proxy 170 | 171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 172 | return ^id(id attribute, NSLayoutRelation relation) { 173 | if ([attribute isKindOfClass:NSArray.class]) { 174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation"); 175 | NSMutableArray *children = NSMutableArray.new; 176 | for (id attr in attribute) { 177 | MASViewConstraint *viewConstraint = [self copy]; 178 | viewConstraint.secondViewAttribute = attr; 179 | [children addObject:viewConstraint]; 180 | } 181 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children]; 182 | compositeConstraint.delegate = self.delegate; 183 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint]; 184 | return compositeConstraint; 185 | } else { 186 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation"); 187 | self.layoutRelation = relation; 188 | self.secondViewAttribute = attribute; 189 | return self; 190 | } 191 | }; 192 | } 193 | 194 | #pragma mark - Semantic properties 195 | 196 | - (MASConstraint *)with { 197 | return self; 198 | } 199 | 200 | - (MASConstraint *)and { 201 | return self; 202 | } 203 | 204 | #pragma mark - attribute chaining 205 | 206 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 207 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation"); 208 | 209 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 210 | } 211 | 212 | #pragma mark - Animator proxy 213 | 214 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 215 | 216 | - (MASConstraint *)animator { 217 | self.useAnimator = YES; 218 | return self; 219 | } 220 | 221 | #endif 222 | 223 | #pragma mark - debug helpers 224 | 225 | - (MASConstraint * (^)(id))key { 226 | return ^id(id key) { 227 | self.mas_key = key; 228 | return self; 229 | }; 230 | } 231 | 232 | #pragma mark - NSLayoutConstraint constant setters 233 | 234 | - (void)setInsets:(MASEdgeInsets)insets { 235 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 236 | switch (layoutAttribute) { 237 | case NSLayoutAttributeLeft: 238 | case NSLayoutAttributeLeading: 239 | self.layoutConstant = insets.left; 240 | break; 241 | case NSLayoutAttributeTop: 242 | self.layoutConstant = insets.top; 243 | break; 244 | case NSLayoutAttributeBottom: 245 | self.layoutConstant = -insets.bottom; 246 | break; 247 | case NSLayoutAttributeRight: 248 | case NSLayoutAttributeTrailing: 249 | self.layoutConstant = -insets.right; 250 | break; 251 | default: 252 | break; 253 | } 254 | } 255 | 256 | - (void)setOffset:(CGFloat)offset { 257 | self.layoutConstant = offset; 258 | } 259 | 260 | - (void)setSizeOffset:(CGSize)sizeOffset { 261 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 262 | switch (layoutAttribute) { 263 | case NSLayoutAttributeWidth: 264 | self.layoutConstant = sizeOffset.width; 265 | break; 266 | case NSLayoutAttributeHeight: 267 | self.layoutConstant = sizeOffset.height; 268 | break; 269 | default: 270 | break; 271 | } 272 | } 273 | 274 | - (void)setCenterOffset:(CGPoint)centerOffset { 275 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute; 276 | switch (layoutAttribute) { 277 | case NSLayoutAttributeCenterX: 278 | self.layoutConstant = centerOffset.x; 279 | break; 280 | case NSLayoutAttributeCenterY: 281 | self.layoutConstant = centerOffset.y; 282 | break; 283 | default: 284 | break; 285 | } 286 | } 287 | 288 | #pragma mark - MASConstraint 289 | 290 | - (void)activate { 291 | if ([self supportsActiveProperty] && self.layoutConstraint) { 292 | if (self.hasBeenInstalled) { 293 | return; 294 | } 295 | self.layoutConstraint.active = YES; 296 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self]; 297 | } else { 298 | [self install]; 299 | } 300 | } 301 | 302 | - (void)deactivate { 303 | if ([self supportsActiveProperty]) { 304 | self.layoutConstraint.active = NO; 305 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 306 | } else { 307 | [self uninstall]; 308 | } 309 | } 310 | 311 | - (void)install { 312 | if (self.hasBeenInstalled) { 313 | return; 314 | } 315 | 316 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item; 317 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute; 318 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item; 319 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute; 320 | 321 | // alignment attributes must have a secondViewAttribute 322 | // therefore we assume that is refering to superview 323 | // eg make.left.equalTo(@10) 324 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) { 325 | secondLayoutItem = self.firstViewAttribute.view.superview; 326 | secondLayoutAttribute = firstLayoutAttribute; 327 | } 328 | 329 | MASLayoutConstraint *layoutConstraint 330 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem 331 | attribute:firstLayoutAttribute 332 | relatedBy:self.layoutRelation 333 | toItem:secondLayoutItem 334 | attribute:secondLayoutAttribute 335 | multiplier:self.layoutMultiplier 336 | constant:self.layoutConstant]; 337 | 338 | layoutConstraint.priority = self.layoutPriority; 339 | layoutConstraint.mas_key = self.mas_key; 340 | 341 | if (self.secondViewAttribute.view) { 342 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view]; 343 | NSAssert(closestCommonSuperview, 344 | @"couldn't find a common superview for %@ and %@", 345 | self.firstViewAttribute.view, self.secondViewAttribute.view); 346 | self.installedView = closestCommonSuperview; 347 | } else if (self.firstViewAttribute.isSizeAttribute) { 348 | self.installedView = self.firstViewAttribute.view; 349 | } else { 350 | self.installedView = self.firstViewAttribute.view.superview; 351 | } 352 | 353 | 354 | MASLayoutConstraint *existingConstraint = nil; 355 | if (self.updateExisting) { 356 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint]; 357 | } 358 | if (existingConstraint) { 359 | // just update the constant 360 | existingConstraint.constant = layoutConstraint.constant; 361 | self.layoutConstraint = existingConstraint; 362 | } else { 363 | [self.installedView addConstraint:layoutConstraint]; 364 | self.layoutConstraint = layoutConstraint; 365 | [firstLayoutItem.mas_installedConstraints addObject:self]; 366 | } 367 | } 368 | 369 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint { 370 | // check if any constraints are the same apart from the only mutable property constant 371 | 372 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints 373 | // and they are likely to be added first. 374 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) { 375 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue; 376 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue; 377 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue; 378 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue; 379 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue; 380 | if (existingConstraint.relation != layoutConstraint.relation) continue; 381 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue; 382 | if (existingConstraint.priority != layoutConstraint.priority) continue; 383 | 384 | return (id)existingConstraint; 385 | } 386 | return nil; 387 | } 388 | 389 | - (void)uninstall { 390 | [self.installedView removeConstraint:self.layoutConstraint]; 391 | self.layoutConstraint = nil; 392 | self.installedView = nil; 393 | 394 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self]; 395 | } 396 | 397 | @end 398 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = [self objectAtIndex:i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == (CGFloat)self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = [self objectAtIndex:i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == (CGFloat)self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = [self objectAtIndex:i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | if (prev) { 103 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 104 | make.width.equalTo(@(fixedItemLength)); 105 | if (i == (CGFloat)self.count - 1) {//last one 106 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 107 | } 108 | else { 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | make.width.equalTo(@(fixedItemLength)); 115 | } 116 | }]; 117 | prev = v; 118 | } 119 | } 120 | else { 121 | MAS_VIEW *prev; 122 | for (int i = 0; i < self.count; i++) { 123 | MAS_VIEW *v = [self objectAtIndex:i]; 124 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 125 | if (prev) { 126 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 127 | make.height.equalTo(@(fixedItemLength)); 128 | if (i == (CGFloat)self.count - 1) {//last one 129 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 130 | } 131 | else { 132 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 133 | } 134 | } 135 | else {//first one 136 | make.top.equalTo(tempSuperView).offset(leadSpacing); 137 | make.height.equalTo(@(fixedItemLength)); 138 | } 139 | }]; 140 | prev = v; 141 | } 142 | } 143 | } 144 | 145 | - (MAS_VIEW *)mas_commonSuperviewOfViews 146 | { 147 | MAS_VIEW *commonSuperview = nil; 148 | MAS_VIEW *previousView = nil; 149 | for (id object in self) { 150 | if ([object isKindOfClass:[MAS_VIEW class]]) { 151 | MAS_VIEW *view = (MAS_VIEW *)object; 152 | if (previousView) { 153 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 154 | } else { 155 | commonSuperview = view; 156 | } 157 | previousView = view; 158 | } 159 | } 160 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 161 | return commonSuperview; 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if TARGET_OS_IPHONE 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /LrdAlert/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /LrdAlert/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LrdAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LrdAlert/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LrdAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LrdAlertTableView.h" 11 | #import "CameraAlertView.h" 12 | #import "LrdPasswordAlertView.h" 13 | #import "LrdDateModel.h" 14 | 15 | @interface ViewController () 16 | 17 | @property (nonatomic, strong) NSMutableArray *dataArray; 18 | @property (nonatomic, strong) UIImagePickerController *picker; 19 | @property (nonatomic, strong) CameraAlertView *alertView; 20 | @property (weak, nonatomic) IBOutlet UIImageView *imgView; 21 | 22 | @end 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | // Do any additional setup after loading the view, typically from a nib. 29 | } 30 | 31 | - (NSMutableArray *)dataArray { 32 | if (!_dataArray) { 33 | _dataArray = [NSMutableArray array]; 34 | //添加几个假数据 35 | for (int i=0; i<20; i++) { 36 | NSString *time = [NSString stringWithFormat:@"2016年2月%d日", i]; 37 | NSString *price = [NSString stringWithFormat:@"5%d", i]; 38 | LrdDateModel *temp = [[LrdDateModel alloc] initWithTime:time price:price]; 39 | [self.dataArray addObject:temp]; 40 | } 41 | } 42 | return _dataArray; 43 | } 44 | 45 | - (IBAction)PasswordAlert:(id)sender { 46 | LrdPasswordAlertView *testView = [[LrdPasswordAlertView alloc] initWithFrame:self.view.bounds]; 47 | testView.block = ^(NSString *text){ 48 | NSLog(@"调用了block"); 49 | }; 50 | [testView pop]; 51 | } 52 | - (IBAction)tableAlertView:(id)sender { 53 | LrdAlertTableView *view = [[LrdAlertTableView alloc] initWithFrame:self.view.bounds]; 54 | //传入数据 55 | view.dataArray = self.dataArray; 56 | 57 | [view pop]; 58 | } 59 | - (IBAction)cameraAlert:(id)sender { 60 | self.alertView = nil; 61 | self.alertView = [[CameraAlertView alloc] initWithFrame:self.view.bounds]; 62 | self.alertView.delegate = self; 63 | [self.alertView pop]; 64 | } 65 | 66 | - (void)buttonClickedWithType:(LrdAlertButtonType)type { 67 | self.picker = nil; 68 | self.picker = [[UIImagePickerController alloc] init]; 69 | self.picker.delegate = self; 70 | if (type == LrdAlertButtonTypeCamera) { 71 | self.picker.sourceType = UIImagePickerControllerSourceTypeCamera; 72 | [self.alertView dismiss]; 73 | [self presentViewController:self.picker animated:YES completion:nil]; 74 | }else if (type == LrdAlertButtonTypeAlbum) { 75 | self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 76 | [self.alertView dismiss]; 77 | [self presentViewController:self.picker animated:YES completion:nil]; 78 | }else { 79 | [self.alertView dismiss]; 80 | } 81 | } 82 | 83 | #pragma mark picker的代理方法实现 84 | 85 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 86 | [self.picker dismissViewControllerAnimated:YES completion:^{ 87 | 88 | }]; 89 | self.imgView.image = [info valueForKey:UIImagePickerControllerOriginalImage]; 90 | 91 | } 92 | 93 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 94 | [self.picker dismissViewControllerAnimated:YES completion:^{ 95 | }]; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /LrdAlert/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LrdAlert 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. 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 | -------------------------------------------------------------------------------- /LrdAlertTests/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 | -------------------------------------------------------------------------------- /LrdAlertTests/LrdAlertTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdAlertTests.m 3 | // LrdAlertTests 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LrdAlertTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation LrdAlertTests 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 | -------------------------------------------------------------------------------- /LrdAlertUITests/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 | -------------------------------------------------------------------------------- /LrdAlertUITests/LrdAlertUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LrdAlertUITests.m 3 | // LrdAlertUITests 4 | // 5 | // Created by 键盘上的舞者 on 3/28/16. 6 | // Copyright © 2016 键盘上的舞者. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LrdAlertUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation LrdAlertUITests 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 | # LrdAlertView 2 | 常见的几种APP弹框形式:
3 | 演示如下图所示:
4 | ![演示](http://lrdup888.qiniudn.com/%E5%B8%B8%E8%A7%81%E5%BC%B9%E7%AA%97%E6%95%88%E6%9E%9C.gif) 5 | 6 | ## 使用方法 7 | clone下来的工程里面包含三个文件夹,对应着三种view,使用时需要导入masonry第三方库。
8 | block是当密码输入完成后调用的,text则为你输入的密码。
9 | 你可以如下面代码类似去调用它: 10 | ```Objective-C 11 | - (IBAction)pop:(id)sender { 12 | LrdPasswordAlertView *testView = [[LrdPasswordAlertView alloc] initWithFrame:self.view.bounds]; 13 | testView.block = ^(NSString *text){ 14 | NSLog(@"调用了block"); 15 | }; 16 | [testView pop]; 17 | } 18 | ``` 19 | 值得注意的是,如果使用CameraView,需要实现UIImagePickerController的代理,详细使用请参考Demo。 20 | 21 | 喜欢就给颗星呗~ 22 | 23 | 我的博客地址:[我的博客](http://www.lrdup.net "键盘上的舞者") 24 | --------------------------------------------------------------------------------