├── README.md ├── WMZRouter.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── apple.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── WMZRouter.xcscheme ├── WMZRouter ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── 0.imageset │ │ ├── 0.jpg │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Expand(拓展) │ ├── 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 │ ├── WMZAlert │ │ ├── WMZAlert.h │ │ └── WMZAlert.m │ ├── WMZTableView │ │ ├── WMZTableView.h │ │ └── WMZTableView.m │ └── WMZUI │ │ ├── WMZRouterAop.h │ │ ├── WMZRouterAop.m │ │ ├── WMZUI.h │ │ └── WMZUI.m ├── Info.plist ├── Main(主要) │ ├── Model │ │ ├── BaseObject.h │ │ ├── BaseObject.m │ │ ├── NewsModel.h │ │ ├── NewsModel.m │ │ ├── WMZModel.h │ │ └── WMZModel.m │ ├── NetWork │ │ ├── NetWorkTool.h │ │ └── NetWorkTool.m │ ├── Tool │ │ ├── WMZCheckNumTool.h │ │ ├── WMZCheckNumTool.m │ │ ├── WMZCommon.h │ │ ├── WMZSingleVC.h │ │ └── WMZSingleVC.m │ ├── VC │ │ ├── BaseTabVC.h │ │ ├── BaseTabVC.m │ │ ├── BaseVC.h │ │ ├── BaseVC.m │ │ ├── FailVC.h │ │ ├── FailVC.m │ │ ├── H5.h │ │ ├── H5.m │ │ ├── HomeVC.h │ │ ├── HomeVC.m │ │ ├── LoginVC.h │ │ ├── LoginVC.m │ │ ├── MineVC.h │ │ ├── MineVC.m │ │ ├── NewsVC.h │ │ ├── NewsVC.m │ │ ├── PersonVC.h │ │ ├── PersonVC.m │ │ ├── ReginerVC.h │ │ ├── ReginerVC.m │ │ ├── WebVC.h │ │ └── WebVC.m │ └── View │ │ ├── BaseCell.h │ │ ├── BaseCell.m │ │ ├── BaseView.h │ │ ├── BaseView.m │ │ ├── NewCell.h │ │ ├── NewCell.m │ │ ├── ViewClass.h │ │ └── ViewClass.m ├── PrefixHeader.pch ├── WMZRouter │ ├── Aspects.h │ ├── Aspects.m │ ├── WMZBaseAop.h │ ├── WMZBaseAop.m │ ├── WMZRequest.h │ ├── WMZRequest.m │ ├── WMZRouteBase.h │ ├── WMZRouteBase.m │ ├── WMZRouter+Expand.h │ ├── WMZRouter+Expand.m │ ├── WMZRouter.h │ ├── WMZRouter.m │ ├── WMZRouterParam.h │ ├── WMZRouterParam.m │ └── WMZRouterProtocol.h └── main.m ├── WMZRouterTests ├── Info.plist └── WMZRouterTests.m └── WMZRouterUITests ├── Info.plist └── WMZRouterUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # WMZRouter 2 | 简单易使用的路由 3 | -------------------------------------------------------------------------------- /WMZRouter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WMZRouter.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /WMZRouter.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/WMZRouter.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 | -------------------------------------------------------------------------------- /WMZRouter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZRouter/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | @interface AppDelegate () 11 | 12 | @end 13 | 14 | @implementation AppDelegate 15 | 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | 19 | // //先配置公共拦截器 20 | // [[WMZBaseAop shareInstance] addAllAop]; 21 | // //配置自己的拦截器类 22 | // [[WMZRouter shareInstance] handleWithURL:RouterURL().target(@"WMZAop").action(@"addAllAop") WithParam:nil]; 23 | 24 | 25 | id url = RouterURL().target(@"getLoginVC"); 26 | id parm = RouterParam().enterVCStyle(RouterRootNa); 27 | [[WMZRouter shareInstance] handleWithURL:url WithParam:parm]; 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // 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. 33 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 34 | } 35 | 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // 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. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | } 41 | 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 45 | } 46 | 47 | 48 | - (void)applicationDidBecomeActive:(UIApplication *)application { 49 | // 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. 50 | } 51 | 52 | 53 | - (void)applicationWillTerminate:(UIApplication *)application { 54 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 55 | } 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /WMZRouter/Assets.xcassets/0.imageset/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wwmz/WMZRouter/b520564aeedbb2583c3042ccf6fa6e1330e0ce53/WMZRouter/Assets.xcassets/0.imageset/0.jpg -------------------------------------------------------------------------------- /WMZRouter/Assets.xcassets/0.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "0.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /WMZRouter/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /WMZRouter/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /WMZRouter/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 | -------------------------------------------------------------------------------- /WMZRouter/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 || TARGET_OS_TV) 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)setInset:(CGFloat)inset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.inset = inset; 135 | } 136 | } 137 | 138 | - (void)setOffset:(CGFloat)offset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.offset = offset; 141 | } 142 | } 143 | 144 | - (void)setSizeOffset:(CGSize)sizeOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.sizeOffset = sizeOffset; 147 | } 148 | } 149 | 150 | - (void)setCenterOffset:(CGPoint)centerOffset { 151 | for (MASConstraint *constraint in self.childConstraints) { 152 | constraint.centerOffset = centerOffset; 153 | } 154 | } 155 | 156 | #pragma mark - MASConstraint 157 | 158 | - (void)activate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint activate]; 161 | } 162 | } 163 | 164 | - (void)deactivate { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | [constraint deactivate]; 167 | } 168 | } 169 | 170 | - (void)install { 171 | for (MASConstraint *constraint in self.childConstraints) { 172 | constraint.updateExisting = self.updateExisting; 173 | [constraint install]; 174 | } 175 | } 176 | 177 | - (void)uninstall { 178 | for (MASConstraint *constraint in self.childConstraints) { 179 | [constraint uninstall]; 180 | } 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 31 | */ 32 | - (MASConstraint * (^)(CGFloat inset))inset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 38 | */ 39 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant, 43 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 44 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 45 | */ 46 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 47 | 48 | /** 49 | * Modifies the NSLayoutConstraint constant 50 | */ 51 | - (MASConstraint * (^)(CGFloat offset))offset; 52 | 53 | /** 54 | * Modifies the NSLayoutConstraint constant based on a value type 55 | */ 56 | - (MASConstraint * (^)(NSValue *value))valueOffset; 57 | 58 | /** 59 | * Sets the NSLayoutConstraint multiplier property 60 | */ 61 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 62 | 63 | /** 64 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 65 | */ 66 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 67 | 68 | /** 69 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 70 | */ 71 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 72 | 73 | /** 74 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 75 | */ 76 | - (MASConstraint * (^)(void))priorityLow; 77 | 78 | /** 79 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 80 | */ 81 | - (MASConstraint * (^)(void))priorityMedium; 82 | 83 | /** 84 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 85 | */ 86 | - (MASConstraint * (^)(void))priorityHigh; 87 | 88 | /** 89 | * Sets the constraint relation to NSLayoutRelationEqual 90 | * returns a block which accepts one of the following: 91 | * MASViewAttribute, UIView, NSValue, NSArray 92 | * see readme for more details. 93 | */ 94 | - (MASConstraint * (^)(id attr))equalTo; 95 | 96 | /** 97 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 98 | * returns a block which accepts one of the following: 99 | * MASViewAttribute, UIView, NSValue, NSArray 100 | * see readme for more details. 101 | */ 102 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 103 | 104 | /** 105 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 106 | * returns a block which accepts one of the following: 107 | * MASViewAttribute, UIView, NSValue, NSArray 108 | * see readme for more details. 109 | */ 110 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 111 | 112 | /** 113 | * Optional semantic property which has no effect but improves the readability of constraint 114 | */ 115 | - (MASConstraint *)with; 116 | 117 | /** 118 | * Optional semantic property which has no effect but improves the readability of constraint 119 | */ 120 | - (MASConstraint *)and; 121 | 122 | /** 123 | * Creates a new MASCompositeConstraint with the called attribute and reciever 124 | */ 125 | - (MASConstraint *)left; 126 | - (MASConstraint *)top; 127 | - (MASConstraint *)right; 128 | - (MASConstraint *)bottom; 129 | - (MASConstraint *)leading; 130 | - (MASConstraint *)trailing; 131 | - (MASConstraint *)width; 132 | - (MASConstraint *)height; 133 | - (MASConstraint *)centerX; 134 | - (MASConstraint *)centerY; 135 | - (MASConstraint *)baseline; 136 | 137 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 138 | 139 | - (MASConstraint *)firstBaseline; 140 | - (MASConstraint *)lastBaseline; 141 | 142 | #endif 143 | 144 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 145 | 146 | - (MASConstraint *)leftMargin; 147 | - (MASConstraint *)rightMargin; 148 | - (MASConstraint *)topMargin; 149 | - (MASConstraint *)bottomMargin; 150 | - (MASConstraint *)leadingMargin; 151 | - (MASConstraint *)trailingMargin; 152 | - (MASConstraint *)centerXWithinMargins; 153 | - (MASConstraint *)centerYWithinMargins; 154 | 155 | #endif 156 | 157 | 158 | /** 159 | * Sets the constraint debug name 160 | */ 161 | - (MASConstraint * (^)(id key))key; 162 | 163 | // NSLayoutConstraint constant Setters 164 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 170 | */ 171 | - (void)setInsets:(MASEdgeInsets)insets; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 177 | */ 178 | - (void)setInset:(CGFloat)inset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant, 182 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 183 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 184 | */ 185 | - (void)setSizeOffset:(CGSize)sizeOffset; 186 | 187 | /** 188 | * Modifies the NSLayoutConstraint constant, 189 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 190 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 191 | */ 192 | - (void)setCenterOffset:(CGPoint)centerOffset; 193 | 194 | /** 195 | * Modifies the NSLayoutConstraint constant 196 | */ 197 | - (void)setOffset:(CGFloat)offset; 198 | 199 | 200 | // NSLayoutConstraint Installation support 201 | 202 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 203 | /** 204 | * Whether or not to go through the animator proxy when modifying the constraint 205 | */ 206 | @property (nonatomic, copy, readonly) MASConstraint *animator; 207 | #endif 208 | 209 | /** 210 | * Activates an NSLayoutConstraint if it's supported by an OS. 211 | * Invokes install otherwise. 212 | */ 213 | - (void)activate; 214 | 215 | /** 216 | * Deactivates previously installed/activated NSLayoutConstraint. 217 | */ 218 | - (void)deactivate; 219 | 220 | /** 221 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 222 | */ 223 | - (void)install; 224 | 225 | /** 226 | * Removes previously installed NSLayoutConstraint 227 | */ 228 | - (void)uninstall; 229 | 230 | @end 231 | 232 | 233 | /** 234 | * Convenience auto-boxing macros for MASConstraint methods. 235 | * 236 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 237 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 238 | */ 239 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 240 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 241 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 242 | 243 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 244 | 245 | 246 | #ifdef MAS_SHORTHAND_GLOBALS 247 | 248 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 249 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 250 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 251 | 252 | #define offset(...) mas_offset(__VA_ARGS__) 253 | 254 | #endif 255 | 256 | 257 | @interface MASConstraint (AutoboxingSupport) 258 | 259 | /** 260 | * Aliases to corresponding relation methods (for shorthand macros) 261 | * Also needed to aid autocompletion 262 | */ 263 | - (MASConstraint * (^)(id attr))mas_equalTo; 264 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 265 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 266 | 267 | /** 268 | * A dummy method to aid autocompletion 269 | */ 270 | - (MASConstraint * (^)(id offset))mas_offset; 271 | 272 | @end 273 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstraint are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 (NS_NOESCAPE ^)(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 (NS_NOESCAPE ^)(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 (NS_NOESCAPE ^)(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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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[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 == 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[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 == 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[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 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 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | 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."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 138 | 139 | - (MASViewAttribute *)mas_safeAreaLayoutGuide { 140 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 141 | } 142 | - (MASViewAttribute *)mas_safeAreaLayoutGuideTop { 143 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 144 | } 145 | - (MASViewAttribute *)mas_safeAreaLayoutGuideBottom { 146 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 147 | } 148 | - (MASViewAttribute *)mas_safeAreaLayoutGuideLeft { 149 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft]; 150 | } 151 | - (MASViewAttribute *)mas_safeAreaLayoutGuideRight { 152 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight]; 153 | } 154 | 155 | #endif 156 | 157 | #pragma mark - associated properties 158 | 159 | - (id)mas_key { 160 | return objc_getAssociatedObject(self, @selector(mas_key)); 161 | } 162 | 163 | - (void)setMas_key:(id)key { 164 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 165 | } 166 | 167 | #pragma mark - heirachy 168 | 169 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 170 | MAS_VIEW *closestCommonSuperview = nil; 171 | 172 | MAS_VIEW *secondViewSuperview = view; 173 | while (!closestCommonSuperview && secondViewSuperview) { 174 | MAS_VIEW *firstViewSuperview = self; 175 | while (!closestCommonSuperview && firstViewSuperview) { 176 | if (secondViewSuperview == firstViewSuperview) { 177 | closestCommonSuperview = secondViewSuperview; 178 | } 179 | firstViewSuperview = firstViewSuperview.superview; 180 | } 181 | secondViewSuperview = secondViewSuperview.superview; 182 | } 183 | return closestCommonSuperview; 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 53 | 54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | 59 | #endif 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 64 | 65 | @end 66 | 67 | #define MAS_ATTR_FORWARD(attr) \ 68 | - (MASViewAttribute *)attr { \ 69 | return [self mas_##attr]; \ 70 | } 71 | 72 | @implementation MAS_VIEW (MASShorthandAdditions) 73 | 74 | MAS_ATTR_FORWARD(top); 75 | MAS_ATTR_FORWARD(left); 76 | MAS_ATTR_FORWARD(bottom); 77 | MAS_ATTR_FORWARD(right); 78 | MAS_ATTR_FORWARD(leading); 79 | MAS_ATTR_FORWARD(trailing); 80 | MAS_ATTR_FORWARD(width); 81 | MAS_ATTR_FORWARD(height); 82 | MAS_ATTR_FORWARD(centerX); 83 | MAS_ATTR_FORWARD(centerY); 84 | MAS_ATTR_FORWARD(baseline); 85 | 86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 87 | 88 | MAS_ATTR_FORWARD(firstBaseline); 89 | MAS_ATTR_FORWARD(lastBaseline); 90 | 91 | #endif 92 | 93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 94 | 95 | MAS_ATTR_FORWARD(leftMargin); 96 | MAS_ATTR_FORWARD(rightMargin); 97 | MAS_ATTR_FORWARD(topMargin); 98 | MAS_ATTR_FORWARD(bottomMargin); 99 | MAS_ATTR_FORWARD(leadingMargin); 100 | MAS_ATTR_FORWARD(trailingMargin); 101 | MAS_ATTR_FORWARD(centerXWithinMargins); 102 | MAS_ATTR_FORWARD(centerYWithinMargins); 103 | 104 | #endif 105 | 106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 107 | 108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop); 109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom); 110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft); 111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight); 112 | 113 | #endif 114 | 115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 116 | return [self mas_attribute]; 117 | } 118 | 119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 120 | return [self mas_makeConstraints:block]; 121 | } 122 | 123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 124 | return [self mas_updateConstraints:block]; 125 | } 126 | 127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 128 | return [self mas_remakeConstraints:block]; 129 | } 130 | 131 | @end 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/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 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/WMZAlert/WMZAlert.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZAlert.h 3 | // WMZAlert 4 | // 5 | // Created by wmz on 2018/10/9. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^NavClickBlock)(id anyID); 12 | 13 | typedef enum : NSUInteger{ 14 | AlertTypeNornal, //默认弹窗 15 | AlertTypeAuto, //默认弹窗自动消失 16 | AlertTypeSystemPush, //系统弹窗 17 | AlertTypeSystemSheet, //系统底部弹窗 18 | AlertTypePay, //支付密码框 19 | AlertTypeToast, //顶部显示弹窗 20 | AlertTypeWrite, //带编辑框的弹窗 21 | AlertTypeTime, //带倒计时的弹窗 22 | AlertTypeSelect, //带选择的弹窗 23 | AlertTypeShare //带分享的弹窗 24 | }AlertType; 25 | 26 | @interface WMZAlert : UIViewController 27 | 28 | /* 29 | * 初始化 30 | */ 31 | + (instancetype)shareInstance; 32 | 33 | /* 34 | * 简单化弹窗没有回调 35 | * 36 | * @param AlertType 弹窗类型 37 | * @param text 显示内容 38 | * 39 | */ 40 | - (void)showAlertWithType:(AlertType)type 41 | textTitle:(id)text; 42 | 43 | /* 44 | * 简单化弹窗带回调 45 | * 46 | * @param AlertType 弹窗类型 47 | * @param title 标题内容 48 | * @param text 显示内容 49 | * @param leftBlock 取消按钮点击回调 50 | * @param rightBlock 确定按钮点击回调 51 | * 52 | */ 53 | - (void)showAlertWithType:(AlertType)type 54 | headTitle:(NSString*)title 55 | textTitle:(id)text 56 | leftHandle:(NavClickBlock)leftBlock 57 | rightHandle:(NavClickBlock)rightBlock; 58 | 59 | /* 60 | * 最全面弹窗可以设置按钮颜色等 61 | * 62 | * @param AlertType 弹窗类型 63 | * @param VC 显示的VC 64 | * @param leftText 取消按钮文字内容 65 | * @param rightText 确定按钮文字内容 66 | * @param title 标题内容 67 | * @param text 显示内容 68 | * @param titleColor 标题内容颜色 69 | * @param textColor 显示内容颜色 70 | * @param backColor 背景颜色 71 | * @param okColor 确定按钮文字颜色 72 | * @param cancelColor 取消按钮文字颜色 73 | * @param leftBlock 取消按钮点击回调 74 | * @param rightBlock 确定按钮点击回调 75 | * 76 | */ 77 | - (void)showAlertWithType:(AlertType)type 78 | sueprVC:(UIViewController*)VC 79 | leftTitle:(NSString*)leftText 80 | rightTitle:(NSString*)rightText 81 | headTitle:(NSString*)title 82 | textTitle:(id)text 83 | headTitleColor:(UIColor*)titleColor 84 | textTitleColor:(UIColor*)textColor 85 | backColor:(UIColor*)backColor 86 | okBtnColor:(UIColor*)okColor 87 | cancelBtnColor:(UIColor*)cancelColor 88 | leftHandle:(NavClickBlock)leftBlock 89 | rightHandle:(NavClickBlock)rightBlock; 90 | @end 91 | 92 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/WMZTableView/WMZTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZTableView.h 3 | // WMZTableView 4 | // 5 | // Created by wmz on 2018/10/22. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Masonry.h" 11 | 12 | @protocol WMZTableViewDelegate 13 | 14 | @optional //非必实现的方法 15 | 16 | /* 17 | * 头视图标题 如需调用此方法则tableView的头视图需要设为nil 才能生效 18 | */ 19 | - (NSString*)WMZTableViewTitleForFooterInSection:(NSInteger)section; 20 | 21 | /* 22 | * 尾视图标题 如需调用此方法则tableView的头视图需要设为nil 才能生效 23 | */ 24 | - (NSString*)WMZTableViewTitleForHeaderInSection:(NSInteger)section; 25 | 26 | /* 27 | * 设置删除/添加的样式 28 | */ 29 | -(UITableViewCellEditingStyle)WMZTableViewEditingStyleForRowAtIndexPath:(NSIndexPath *)indexPath; 30 | 31 | /* 32 | * 设置删除/添加的样式的显示内容 33 | */ 34 | -(NSString *)WMZTableViewTitleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 35 | 36 | /* 37 | * 删除/添加的样式的点击方法 38 | */ 39 | - (void)WMZTableViewCommitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath; 40 | 41 | /* 42 | * cell将显示的方法 43 | */ 44 | - (void)WMZTableViewWillDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; 45 | 46 | @end 47 | 48 | //点击回调 49 | typedef void (^ClickBlock)(id anyID); 50 | 51 | //布局 52 | typedef void(^WMZConstraint) (MASConstraintMaker *make); 53 | 54 | //设置cell回调 55 | typedef UITableViewCell* (^CellShowBlock)(id model,NSIndexPath *indexPath); 56 | 57 | //设置cell数量 58 | typedef NSInteger (^CellCount)(NSInteger section); 59 | 60 | //设置cellh高度 61 | typedef NSInteger (^CellHeight)(NSIndexPath *indexPath); 62 | 63 | //设置头视图高度 64 | typedef NSInteger (^HeadHeight)(NSInteger section); 65 | 66 | //设置尾视图高度 67 | typedef NSInteger (^FootHeight)(NSInteger section); 68 | 69 | //设置头视图 70 | typedef UIView * (^HeadView)(NSInteger section); 71 | 72 | //设置尾视图 73 | typedef UIView * (^FootView)(NSInteger section); 74 | 75 | typedef enum : NSUInteger{ 76 | CellTypeNornal, 77 | CellTypeAuto 78 | }CellType; 79 | @interface WMZTableView : UITableView 80 | 81 | @property(nonatomic,weak) id WMZdelegate; 82 | 83 | /* 84 | * 初始化 Grouped 85 | */ 86 | + (instancetype)shareGrouped; 87 | 88 | /* 89 | * 初始化 Plain 90 | */ 91 | + (instancetype)sharePlain; 92 | 93 | 94 | /* 95 | * 更新 96 | * 97 | * @param data 数据 98 | * 99 | */ 100 | - (void)updateWithData:(NSArray*)data; 101 | 102 | /* 103 | * 封装tableview常用属性 基于masonry 104 | * 105 | * @param type 类型 106 | * @param make tableView的布局 107 | * @param superView 父视图 108 | * @param data 数据源 109 | * @param cellNameArr 多种cell的类名 传NSString的集合数组 需要先注册实现复用 110 | * @param showBlock 显示的cell 111 | * @param countBlock 显示的cell的数量 112 | * @param block 点击的回调 113 | * 114 | */ 115 | - (WMZTableView*)addTableViewWithType:(CellType)type 116 | withConstraint:(WMZConstraint)make 117 | withSuperView:(UIView*)superView 118 | withData:(id)data 119 | withCellName:(NSArray*)cellNameArr 120 | WithCellShow:(CellShowBlock)showBlock 121 | WithCellCount:(CellCount)countBlock 122 | Handle:(ClickBlock)block; 123 | 124 | 125 | /* 126 | * 封装tableview常用属性 基于masonry 127 | * 128 | * @param type 类型 129 | * @param make tableView的布局 130 | * @param superView 父视图 131 | * @param data 数据源 132 | * @param showBlock 显示的cell 133 | * @param block 点击的回调 134 | * 135 | */ 136 | - (WMZTableView*)addTableViewWithType:(CellType)type 137 | withConstraint:(WMZConstraint)make 138 | withSuperView:(UIView*)superView 139 | withData:(id)data 140 | WithCellShow:(CellShowBlock)showBlock 141 | Handle:(ClickBlock)block; 142 | 143 | /* 144 | * 封装tableview 基于masonry (可设置头尾视图) 145 | * 146 | * @param type 类型 147 | * @param make tableView的布局 148 | * @param superView 父视图 149 | * @param data 数据源 150 | * @param section 多少列 151 | * @param cellNameArr 多种cell的类名 传NSString的集合数组 需要先注册实现复用 152 | * @param showBlock 显示的cell 153 | * @param countBlock 显示的cell的数量 154 | * @param heightBlock cell的高度 155 | * @param headHeightBlock 头部视图高度 156 | * @param footHeightBlock 尾部视图高度 157 | * @param headViewBlock 头部视图 158 | * @param footViewBlock 尾部视图 159 | * @param block 点击的回调 160 | * 161 | */ 162 | - (WMZTableView*)addTableViewWithType:(CellType)type 163 | withConstraint:(WMZConstraint)make 164 | withSuperView:(UIView*)superView 165 | withData:(id)data 166 | withSection:(NSInteger)section 167 | withCellName:(NSArray*)cellNameArr 168 | WithCellShow:(CellShowBlock)showBlock 169 | WithCellCount:(CellCount)countBlock 170 | WithCellHeight:(CellHeight)heightBlock 171 | WithHeadHeight:(HeadHeight)headHeightBlock 172 | WithFootHeight:(FootHeight)footHeightBlock 173 | WithHeadView:(HeadView)headViewBlock 174 | WithFootView:(FootView)footViewBlock 175 | Handle:(ClickBlock)block; 176 | 177 | 178 | @end 179 | 180 | 181 | //自定义cell 可以自己设置 182 | @interface NornalCell : UITableViewCell 183 | 184 | @property(nonatomic,strong)UILabel *myLabel; 185 | 186 | @property(nonatomic,strong)id model; 187 | 188 | 189 | 190 | @end 191 | 192 | @interface NornalCellOne : UITableViewCell 193 | 194 | @property(nonatomic,strong)UILabel *myLabel; 195 | 196 | @property(nonatomic,strong)UIImageView *icon; 197 | 198 | @end 199 | 200 | @interface NornalCellSecond : UITableViewCell 201 | 202 | @property(nonatomic,strong)UIImageView *icon; 203 | 204 | @end 205 | -------------------------------------------------------------------------------- /WMZRouter/Expand(拓展)/WMZUI/WMZRouterAop.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterAop.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/21. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | #import "BaseObject.h" 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | 13 | @interface WMZRouterAopModel:NSObject 14 | 15 | // 拦截器类型 前还是后 16 | @property(nonatomic,assign) NSInteger options; 17 | 18 | // 顺序(同个方法的优先级) 前拦截 数字小的优先级大 后拦截 数字大的优先级大 19 | @property(nonatomic,assign) NSInteger sort; 20 | 21 | // 方法名编码 相同方法名对应的要相同 22 | @property(nonatomic,assign) NSInteger actionNameType; 23 | 24 | // 拦截器方法名 25 | @property(nonatomic,copy) NSString* selectorName; 26 | 27 | - (instancetype)initWithOptions:(NSInteger)options Sort:(NSInteger)sort ActionNameType:(NSInteger)actionNameType; 28 | 29 | @end 30 | 31 | 32 | @interface WMZRouterAop : NSObject 33 | 34 | /* 35 | * 初始化 36 | */ 37 | + (instancetype)shareInstance; 38 | 39 | 40 | 41 | 42 | /* 43 | * 添加本类的所有拦截操作 44 | */ 45 | - (void)addAllAop; 46 | 47 | /* 48 | * 拦截非调用本app的操作 49 | */ 50 | + (WMZRouterAopModel*)dealWithOpenURL:(NSNumber*)shouldReturn; 51 | 52 | /* 53 | * 权限设置 54 | */ 55 | + (WMZRouterAopModel*)setPermissions:(NSNumber*)shouldReturn; 56 | 57 | /* 58 | * 数据缓存 59 | */ 60 | + (WMZRouterAopModel*)dataCache:(NSNumber*)shouldReturn; 61 | 62 | /* 63 | * 处理特殊参数 64 | */ 65 | + (WMZRouterAopModel*)dealWithspecialParameters:(NSNumber*)shouldReturn; 66 | 67 | /* 68 | * 清理handle缓存 69 | */ 70 | + (WMZRouterAopModel*)clean:(NSNumber*)shouldReturn; 71 | 72 | /* 73 | * 错误处理 74 | */ 75 | + (WMZRouterAopModel*)dealWitherror:(NSNumber*)shouldReturn; 76 | 77 | 78 | //实现方法名字需与协议定制的方法一样 79 | 80 | /* 81 | * 拦截非调用本app的操作 82 | */ 83 | + (BOOL)candealWithOpenURL:(NSNumber*)can; 84 | 85 | /* 86 | * 权限设置 87 | */ 88 | + (BOOL)canPermissions:(NSNumber*)can; 89 | /* 90 | * 数据缓存 91 | */ 92 | + (BOOL)candataCache:(NSNumber*)can; 93 | 94 | /* 95 | * 处理特殊参数 96 | */ 97 | + (BOOL)candealWithspecialParameters:(NSNumber*)can; 98 | /* 99 | * 清理handle缓存 100 | */ 101 | + (BOOL)canclean:(NSNumber*)can; 102 | /* 103 | * 错误处理 104 | */ 105 | + (BOOL)candealWitherror:(NSNumber*)can; 106 | 107 | @end 108 | 109 | NS_ASSUME_NONNULL_END 110 | -------------------------------------------------------------------------------- /WMZRouter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleURLTypes 20 | 21 | 22 | CFBundleTypeRole 23 | Editor 24 | CFBundleURLSchemes 25 | 26 | 27 | 28 | CFBundleVersion 29 | 1 30 | LSRequiresIPhoneOS 31 | 32 | 33 | 34 | 35 | 36 | NSAppTransportSecurity 37 | 38 | NSAllowsArbitraryLoads 39 | 40 | 41 | 42 | NSPhotoLibraryUsageDescription 43 | App需要您的同意,才能访问相册 44 | 45 | NSCameraUsageDescription 46 | App需要您的同意,才能访问相机 47 | 48 | NSMicrophoneUsageDescription 49 | App需要您的同意,才能访问麦克风 50 | 51 | NSLocationUsageDescription 52 | App需要您的同意,才能访问位置 53 | 54 | NSLocationWhenInUseUsageDescription 55 | App需要您的同意,才能在使用期间访问位置 56 | 57 | NSLocationAlwaysUsageDescription 58 | App需要您的同意,才能始终访问位置 59 | 60 | NSCalendarsUsageDescription 61 | App需要您的同意,才能访问日历 62 | 63 | NSRemindersUsageDescription 64 | App需要您的同意,才能访问提醒事项 65 | 66 | NSMotionUsageDescription App需要您的同意,才能访问运动与健身 67 | 68 | NSHealthUpdateUsageDescription 69 | App需要您的同意,才能访问健康更新 70 | 71 | NSHealthShareUsageDescription 72 | App需要您的同意,才能访问健康分享 73 | 74 | NSBluetoothPeripheralUsageDescription 75 | App需要您的同意,才能访问蓝牙 76 | 77 | NSAppleMusicUsageDescription 78 | App需要您的同意,才能访问媒体资料库 79 | UILaunchStoryboardName 80 | LaunchScreen 81 | UIMainStoryboardFile 82 | Main 83 | UIRequiredDeviceCapabilities 84 | 85 | armv7 86 | 87 | UISupportedInterfaceOrientations 88 | 89 | UIInterfaceOrientationPortrait 90 | UIInterfaceOrientationLandscapeLeft 91 | UIInterfaceOrientationLandscapeRight 92 | 93 | UISupportedInterfaceOrientations~ipad 94 | 95 | UIInterfaceOrientationPortrait 96 | UIInterfaceOrientationPortraitUpsideDown 97 | UIInterfaceOrientationLandscapeLeft 98 | UIInterfaceOrientationLandscapeRight 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/BaseObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BaseObject : NSObject 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/BaseObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | @implementation BaseObject 12 | 13 | + (NSString *)routerPath{ 14 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/NewsModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewsModel.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface NewsModel : BaseObject 14 | 15 | @property (nonatomic, copy) NSString *title; 16 | 17 | @property (nonatomic, copy) NSString *text; 18 | 19 | @property (nonatomic, copy) NSString *icon; 20 | 21 | @property (nonatomic, copy) NSString *time; 22 | 23 | @property (nonatomic, copy) NSString *ID; 24 | 25 | @end 26 | 27 | NS_ASSUME_NONNULL_END 28 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/NewsModel.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | // 7 | // NewsModel.m 8 | // WMZRouter 9 | // 10 | // Created by wmz on 2018/11/13. 11 | // Copyright © 2018年 wmz. All rights reserved. 12 | // 13 | 14 | #import "NewsModel.h" 15 | 16 | @implementation NewsModel 17 | + (NSString *)routerPath{ 18 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/WMZModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZModel.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface WMZModel : BaseObject 14 | 15 | @property (nonatomic, copy) NSString *name; 16 | 17 | @property (nonatomic, assign) NSInteger age; 18 | 19 | @property (nonatomic, copy) NSString *other; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Model/WMZModel.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // 5 | // WMZModel.m 6 | // WMZRouter 7 | // 8 | // Created by wmz on 2018/11/13. 9 | // Copyright © 2018年 wmz. All rights reserved. 10 | // 11 | 12 | #import "WMZModel.h" 13 | 14 | @implementation WMZModel 15 | - (NSString *)description{ 16 | return [NSString stringWithFormat:@"%@ %ld %@",self.name,self.age,self.other]; 17 | } 18 | + (NSString *)routerPath{ 19 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/NetWork/NetWorkTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // NetWorkTool.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | #define NetWorkResponseBlock void (^)(NSString * resultCode,NSDictionary *post_dic) 9 | #define NetWorkResponseErrorBlock void (^)(NSString * resultCode, NSString *reslut_describe) 10 | #import "BaseObject.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface NetWorkTool : BaseObject 15 | 16 | + (void)netWorkSuccessTestWithSuccessWithParm:(NSDictionary*)dic; 17 | 18 | 19 | + (void)netWorkFailTestWithSuccessWithParm:(NSDictionary*)dic; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/NetWork/NetWorkTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // NetWorkTool.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | 7 | 8 | 9 | 10 | // Copyright © 2018年 wmz. All rights reserved. 11 | // 12 | 13 | #import "NetWorkTool.h" 14 | 15 | @implementation NetWorkTool 16 | 17 | + (void)netWorkSuccessTestWithSuccessWithParm:(NSDictionary*)dic{ 18 | __block WMZRouterCallBlock block = dic[@"block"]; 19 | [self netWorkTestWithSuccessCallBack:^(NSString * _Nonnull resultCode, NSDictionary * _Nonnull post_dic) { 20 | if (block) { 21 | block(@"网路请求成功",YES); 22 | } 23 | } failCallBack:^(NSString * _Nonnull resultCode, NSString * _Nonnull reslut_describe) { 24 | if (block) { 25 | block(@"网路请求失败",NO); 26 | } 27 | }]; 28 | 29 | } 30 | 31 | + (void)netWorkFailTestWithSuccessWithParm:(NSDictionary*)dic{ 32 | WMZRouterCallBlock block = dic[@"block"]; 33 | 34 | [self netWorkTestFailWithSuccessCallBack:^(NSString * _Nonnull resultCode, NSDictionary * _Nonnull post_dic) { 35 | if (block) { 36 | block(@"网路请求成功",YES); 37 | } 38 | } failCallBack:^(NSString * _Nonnull resultCode, NSString * _Nonnull reslut_describe) { 39 | if (block) { 40 | block(@"网路请求失败",NO); 41 | } 42 | }]; 43 | } 44 | 45 | 46 | + (void)netWorkTestWithSuccessCallBack:(NetWorkResponseBlock)successCallBack 47 | failCallBack:(NetWorkResponseErrorBlock)failCallBack{ 48 | //模拟网路条件2秒后再返回 49 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 50 | successCallBack(@"成功",@{}); 51 | }); 52 | } 53 | 54 | + (void)netWorkTestFailWithSuccessCallBack:(NetWorkResponseBlock)successCallBack 55 | failCallBack:(NetWorkResponseErrorBlock)failCallBack{ 56 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 57 | failCallBack(@"失败",nil); 58 | }); 59 | } 60 | 61 | 62 | + (NSString *)routerPath{ 63 | return @"netWorkTest"; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Tool/WMZCheckNumTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZCheckNumTool.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/9. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | #import "BaseObject.h" 9 | @interface WMZCheckNumTool : BaseObject 10 | 11 | //检测登录输入的手机号和密码格式 12 | - (BOOL)checkLoginPhoneAndPassWordWithParam:(NSDictionary*)parma; 13 | 14 | //检测注册输入的手机号和密码格式 15 | - (BOOL)checkReginPhoneAndPassWordWithParam:(NSDictionary*)parma; 16 | 17 | //检测个人信息 18 | - (BOOL)checkInfomation; 19 | 20 | //测试类方法 21 | + (NSString*)leiAction:(NSDictionary*)parma; 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Tool/WMZCheckNumTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZCheckNumTool.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/9. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZCheckNumTool.h" 10 | 11 | @implementation WMZCheckNumTool 12 | - (BOOL)checkReginPhoneAndPassWordWithParam:(NSDictionary*)parma{ 13 | NSString *phone = parma[@"phone"]; 14 | NSString *passWord = parma[@"passWord"]; 15 | BOOL result = NO; 16 | NSString *errorStr = nil; 17 | if (phone&&phone.length>=5&&passWord&&passWord.length>=3) { 18 | NSDictionary *dic = WMZObjectGetNull(UserAccounts); 19 | 20 | result = YES; 21 | if (dic) { 22 | 23 | if (dic[phone]) { 24 | errorStr = @"该手机已经注册过了"; 25 | result = NO; 26 | }else{ 27 | dic = [NSMutableDictionary dictionaryWithDictionary:dic]; 28 | WMZDic(dic, passWord, phone); 29 | WMZObjectSave(dic, UserAccounts); 30 | WMZObjectSave(phone, UserPhone); 31 | } 32 | }else{ 33 | NSMutableDictionary *mdic = [NSMutableDictionary new]; 34 | WMZDic(mdic, passWord, phone); 35 | WMZObjectSave(mdic, UserAccounts); 36 | WMZObjectSave(phone, UserPhone); 37 | 38 | } 39 | 40 | }else{ 41 | errorStr = @"账号或密码不符合规范"; 42 | } 43 | if (errorStr) { 44 | [[WMZAlert shareInstance] showAlertWithType:AlertTypeAuto textTitle:errorStr]; 45 | } 46 | return result; 47 | 48 | } 49 | 50 | - (BOOL)checkLoginPhoneAndPassWordWithParam:(NSDictionary*)parma{ 51 | 52 | NSString *phone = parma[@"phone"]; 53 | NSString *passWord = parma[@"passWord"]; 54 | BOOL result = NO; 55 | NSString *errorStr = nil; 56 | if (phone&&phone.length>=5&&passWord&&passWord.length>=3) { 57 | NSDictionary *dic = WMZObjectGetNull(UserAccounts); 58 | if (dic) { 59 | if (dic[phone]) { 60 | result = YES; 61 | WMZObjectSave(phone, UserPhone); 62 | }else{ 63 | errorStr = @"该账号尚未注册"; 64 | } 65 | }else{ 66 | errorStr = @"该账号尚未注册"; 67 | } 68 | }else{ 69 | errorStr = @"账号或密码不符合规范"; 70 | } 71 | if (errorStr) { 72 | [[WMZAlert shareInstance] showAlertWithType:AlertTypeAuto textTitle:errorStr]; 73 | } 74 | return result; 75 | } 76 | 77 | - (BOOL)checkInfomation{ 78 | NSString *keyName = [NSString stringWithFormat:@"%@_%@",UserName,WMZObjectGet(UserPhone)]; 79 | NSString *keyAge = [NSString stringWithFormat:@"%@_%@",UserAge,WMZObjectGet(UserPhone)]; 80 | NSString *keyMarry = [NSString stringWithFormat:@"%@_%@",UserMarry,WMZObjectGet(UserPhone)]; 81 | if (WMZObjectGetNull(keyName)&&WMZObjectGetNull(keyAge)&&WMZObjectGetNull(keyMarry)) { 82 | return YES; 83 | }else{ 84 | return NO; 85 | } 86 | } 87 | 88 | + (NSString *)routerPath{ 89 | return @"checkTool"; 90 | } 91 | 92 | //测试类方法 93 | + (NSString*)leiAction:(NSDictionary*)parma{ 94 | NSLog(@"类方法%@",parma); 95 | return @"111"; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Tool/WMZCommon.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // WMZCommon.h 4 | // WMZRouter 5 | // 6 | // Created by wmz on 2018/11/12. 7 | // Copyright © 2018年 wmz. All rights reserved. 8 | // 9 | 10 | #ifndef WMZCommon_h 11 | #define WMZCommon_h 12 | static NSString *const UserAccounts = @"UserAccounts"; 13 | static NSString *const UserPhone = @"UserPhone"; 14 | static NSString *const UserPassWord = @"UserPassWord"; 15 | static NSString *const UserName = @"UserName"; 16 | static NSString *const UserAge = @"UserAge"; 17 | static NSString *const UserMarry = @"UserMarry"; 18 | #endif /* WMZCommon_h */ 19 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Tool/WMZSingleVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZSingleVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/14. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface WMZSingleVC : BaseObject 14 | 15 | + (instancetype)shareInstance; 16 | 17 | - (NSString*)shareAction2:(NSDictionary*)paran; 18 | 19 | @property(nonatomic,strong)NSMutableArray *arr; 20 | 21 | @end 22 | 23 | NS_ASSUME_NONNULL_END 24 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/Tool/WMZSingleVC.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | // 4 | // WMZSingleVC.m 5 | // WMZRouter 6 | // 7 | // Created by wmz on 2018/11/14. 8 | // Copyright © 2018年 wmz. All rights reserved. 9 | // 10 | 11 | #import "WMZSingleVC.h" 12 | 13 | @implementation WMZSingleVC 14 | static WMZSingleVC *_instance; 15 | /* 16 | * 初始化 17 | */ 18 | +(instancetype)shareInstance{ 19 | return [[self alloc] init]; 20 | 21 | } 22 | 23 | +(id)allocWithZone:(struct _NSZone *)zone 24 | { 25 | static dispatch_once_t onceToken; 26 | 27 | dispatch_once(&onceToken, ^{ 28 | _instance = [super allocWithZone:zone]; 29 | }); 30 | 31 | return _instance; 32 | } 33 | 34 | - (instancetype)copyWithZone:(NSZone *)zone 35 | { 36 | return _instance; 37 | } 38 | 39 | - (instancetype)mutableCopyWithZone:(NSZone *)zone 40 | { 41 | return _instance; 42 | } 43 | 44 | 45 | 46 | - (NSString*)shareAction2:(NSDictionary*)paran{ 47 | NSString *name = paran[@"name"]; 48 | [self.arr addObject:name]; 49 | NSLog(@"222%@",self.arr); 50 | [[WMZAlert shareInstance]showAlertWithType:AlertTypeAuto textTitle:@"单例方法"]; 51 | return @"222"; 52 | } 53 | 54 | + (NSString *)routerPath{ 55 | return @"shareVC"; 56 | } 57 | 58 | - (NSMutableArray *)arr{ 59 | if (!_arr) { 60 | _arr = [NSMutableArray new]; 61 | } 62 | return _arr; 63 | } 64 | @end 65 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/BaseTabVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseTabVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BaseTabVC : UITabBarController 14 | 15 | @property(nonatomic,copy)NSString *test; 16 | 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/BaseTabVC.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // BaseTabVC.m 4 | // WMZRouter 5 | // 6 | // Created by wmz on 2018/11/13. 7 | // Copyright © 2018年 wmz. All rights reserved. 8 | // 9 | 10 | #import "BaseTabVC.h" 11 | 12 | @interface BaseTabVC () 13 | 14 | @end 15 | 16 | @implementation BaseTabVC 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | NSArray *VCArr = @[ 22 | @{ 23 | @"VCName":@"getHomeVC", 24 | @"fonName":@"HeiTi SC", 25 | @"font":@(13.0f), 26 | @"name":@"HomeVC", 27 | @"selectColor": [UIColor redColor], 28 | @"unselectColor": [UIColor blackColor] 29 | }, 30 | @{ 31 | @"VCName":@"getNewsVC", 32 | @"fonName":@"HeiTi SC", 33 | @"font":@(130.f), 34 | @"name":@"NewsVC", 35 | @"selectColor": [UIColor redColor], 36 | @"unselectColor": [UIColor blackColor] 37 | }, 38 | @{ 39 | @"VCName":@"getMineVC", 40 | @"fonName":@"HeiTi SC", 41 | @"font":@(13.0f), 42 | @"name":@"MineVC", 43 | @"selectColor": [UIColor redColor], 44 | @"unselectColor": [UIColor blackColor] 45 | } 46 | ]; 47 | 48 | // Do any additional setup after loading the view. 49 | NSMutableArray *naArr = [NSMutableArray new]; 50 | for (NSDictionary *dic in VCArr) { 51 | //获取VC 52 | UIViewController *VC = [[WMZRouter shareInstance] handleWithURL:dic[@"VCName"] WithParam:@{}]; 53 | UINavigationController *naVC = [[UINavigationController alloc]initWithRootViewController:VC]; 54 | 55 | [self setTabBarItem:naVC.tabBarItem 56 | title:dic[@"name"] 57 | titleSize:[dic[@"font"] floatValue] 58 | titleFontName:dic[@"fonName"] 59 | selectedImage:nil 60 | selectedTitleColor:dic[@"selectColor"] 61 | normalImage:nil 62 | normalTitleColor:dic[@"unselectColor"]]; 63 | [naArr addObject:naVC]; 64 | } 65 | 66 | 67 | self.viewControllers = [NSArray arrayWithArray:naArr]; 68 | } 69 | 70 | - (void)setTabBarItem:(UITabBarItem *)tabbarItem 71 | title:(NSString *)title 72 | titleSize:(CGFloat)size 73 | titleFontName:(NSString *)fontName 74 | selectedImage:(NSString *)selectedImage 75 | selectedTitleColor:(UIColor *)selectColor 76 | normalImage:(NSString *)unselectedImage 77 | normalTitleColor:(UIColor *)unselectColor 78 | { 79 | tabbarItem.title = title; 80 | tabbarItem.image = [[UIImage imageNamed:unselectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 81 | tabbarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 82 | 83 | // S未选中字体颜色 84 | [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:unselectColor,NSFontAttributeName:[UIFont fontWithName:fontName size:size]} forState:UIControlStateNormal]; 85 | 86 | // 选中字体颜色 87 | [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:selectColor,NSFontAttributeName:[UIFont fontWithName:fontName size:size]} forState:UIControlStateSelected]; 88 | } 89 | 90 | + (NSString *)routerPath{ 91 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 92 | } 93 | /* 94 | #pragma mark - Navigation 95 | 96 | // In a storyboard-based application, you will often want to do a little preparation before navigation 97 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 98 | // Get the new view controller using [segue destinationViewController]. 99 | // Pass the selected object to the new view controller. 100 | } 101 | */ 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/BaseVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface BaseVC : UIViewController 13 | 14 | @end 15 | 16 | NS_ASSUME_NONNULL_END 17 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/BaseVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseVC.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | @interface BaseVC () 12 | 13 | @end 14 | 15 | @implementation BaseVC 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | [self setTitle:NSStringFromClass([self class])]; 21 | self.view.backgroundColor = [UIColor whiteColor]; 22 | } 23 | 24 | 25 | + (NSString *)routerPath{ 26 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 27 | } 28 | 29 | 30 | - (void)dealloc{ 31 | 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/FailVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // FailVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface FailVC : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/FailVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // FailVC.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "FailVC.h" 10 | 11 | @interface FailVC () 12 | 13 | @end 14 | 15 | @implementation FailVC 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view. 20 | [WMZUI newLabelText:@"失败提示页面" TextColor:[UIColor redColor] SuperView:self.view Constraint:^(MASConstraintMaker *make) { 21 | make.center.equalTo(self.view); 22 | }]; 23 | } 24 | 25 | /* 26 | #pragma mark - Navigation 27 | 28 | // In a storyboard-based application, you will often want to do a little preparation before navigation 29 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 30 | // Get the new view controller using [segue destinationViewController]. 31 | // Pass the selected object to the new view controller. 32 | } 33 | */ 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/H5.h: -------------------------------------------------------------------------------- 1 | // 2 | // H5.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface H5 : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/H5.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // H5.m 4 | // WMZRouter 5 | // 6 | // Created by wmz on 2018/11/16. 7 | // Copyright © 2018年 wmz. All rights reserved. 8 | // 9 | 10 | #import "H5.h" 11 | 12 | @interface H5 () 13 | 14 | @end 15 | 16 | @implementation H5 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view. 21 | [WMZUI newLabelText:@"h5页面" TextColor:[UIColor redColor] SuperView:self.view Constraint:^(MASConstraintMaker *make) { 22 | make.center.equalTo(self.view); 23 | }]; 24 | } 25 | 26 | /* 27 | #pragma mark - Navigation 28 | 29 | // In a storyboard-based application, you will often want to do a little preparation before navigation 30 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 31 | // Get the new view controller using [segue destinationViewController]. 32 | // Pass the selected object to the new view controller. 33 | } 34 | */ 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/HomeVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // HomeVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface HomeVC : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/HomeVC.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | // 6 | // HomeVC.m 7 | // WMZRouter 8 | // 9 | // Created by wmz on 2018/11/8. 10 | // Copyright © 2018年 wmz. All rights reserved. 11 | // 12 | 13 | #import "HomeVC.h" 14 | @interface HomeVC () 15 | @property(nonatomic,strong)WMZTableView *table; 16 | @end 17 | 18 | @implementation HomeVC 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | WMZWeakSelf 23 | 24 | self.table = [[WMZTableView sharePlain] addTableViewWithType:0 withConstraint:^(MASConstraintMaker *make) { 25 | make.top.left.right.bottom.mas_equalTo(0); 26 | } withSuperView:self.view withData:@[@"跳转外部网页",@"跳转内部网页",@"网络请求测试成功(等待请求完回调)",@"网络请求测试失败",@"获取headView",@"获取Model",@"跳转其他APP",@"带block",@"获取类的实例方法和类方法",@"获取单例方法",@"错误处理跳转h5",@"错误处理自己处理",@"打电话",@"打开邮箱"] WithCellShow:^UITableViewCell *(id model, NSIndexPath *indexPath) { 27 | 28 | 29 | WMZRouterURL *URL = RouterURL().target(@"getNornalCell"); 30 | WMZRouterParam *param = RouterParam().CellTable(weakSelf.table).log(@"日志"); 31 | UITableViewCell *cell = [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 32 | 33 | if (model) { 34 | [cell setValue:model forKey:@"model"]; 35 | } 36 | return cell; 37 | } Handle:^(id anyID) { 38 | [weakSelf doClick:anyID]; 39 | }]; 40 | 41 | } 42 | 43 | 44 | - (void)doClick:(NSString*)name{ 45 | WMZRouter *route = [WMZRouter shareInstance]; 46 | if ([name isEqualToString:@"跳转外部网页"]) { 47 | WMZRouterURL *URL = RouterURL().openURL(@"http://www.cocoachina.com/ios/20170301/18811.html"); 48 | [route handleWithURL:URL WithParam: RouterParam().openURL()]; 49 | 50 | }else if ([name isEqualToString:@"跳转内部网页"]) { 51 | 52 | id URL = RouterURL().target(@"getWebVC"); 53 | id param = RouterParam().selfParam(@{ 54 | @"URL":[NSURL URLWithString:@"http://www.cocoachina.com/ios/20170301/18811.html"], 55 | @"btnShow":@(YES) 56 | }).enterVCStyle(RouterPushHideTabBackShow); 57 | [route handleWithURL:URL WithParam:param]; 58 | 59 | }else if ([name isEqualToString:@"打电话"]) { 60 | WMZRouterURL *URL = RouterURL().openURL(@"tel://131232312323"); 61 | [route handleWithURL:URL WithParam:RouterParam().openURL()]; 62 | }else if ([name isEqualToString:@"打开邮箱"]) { 63 | id URL = RouterURL().openURL(@"mailto://admin@hzlzh.com"); 64 | [route handleWithURL:URL WithParam:RouterParam().openURL()]; 65 | 66 | }else if ([name isEqualToString:@"获取headView"]) { 67 | 68 | //通过方法获取View 69 | NSString *keyName = [NSString stringWithFormat:@"%@_%@",UserName,WMZObjectGet(UserPhone)]; 70 | NSString *keyMarry = [NSString stringWithFormat:@"%@_%@",UserMarry,WMZObjectGet(UserPhone)]; 71 | 72 | id URL = RouterURL().target(@"getView").actions(@"getHeadViewWithParma"); 73 | id param = RouterParam().permissions(PermissionTypePhoto, ^(id anyID, BOOL success) { 74 | NSLog(@"权限"); 75 | }).log(@"日志").selfParam(@{ 76 | @"name":WMZObjectGet(keyName), 77 | @"detail":WMZObjectGet(keyMarry) 78 | }); 79 | 80 | UIView *headView = [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 81 | 82 | NSLog(@"%@",headView); 83 | [self.table setTableHeaderView:headView]; 84 | }else if ([name isEqualToString:@"获取Model"]) { 85 | 86 | id URL = RouterURL().target(@"getWMZModel"); 87 | id param = RouterParam().selfParam(@{ 88 | @"name":@"WMZ", 89 | @"age":@(20), 90 | @"other":@"其他" 91 | }); 92 | 93 | id model = [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 94 | ; 95 | 96 | 97 | 98 | [[WMZAlert shareInstance] showAlertWithType:AlertTypeNornal textTitle:[NSString stringWithFormat:@"%@",[model valueForKey:@"name"]]]; 99 | }else if ([name isEqualToString:@"跳转其他APP"]) { 100 | 101 | //要跳转的app需要先注册 102 | id URL = RouterURL().target(@"com.WMZAlert://"); 103 | [route handleWithURL:URL WithParam:RouterParam().openURL()]; 104 | 105 | }else if ([name isEqualToString:@"获取类的实例方法和类方法"]) { 106 | 107 | id URL = RouterURL().target(@"checkTool"); 108 | id param = RouterParam().selfParam(@{ 109 | @"phone":@"1111", 110 | @"passWord":@"22222" 111 | }); 112 | 113 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 114 | 115 | }else if ([name isEqualToString:@"带block"]) { 116 | 117 | id URL = RouterURL().target(@"getNornalCell11"); 118 | id param = RouterParam().error(RouterUpdate).enterVCStyle(RouterRoot); 119 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param WithHandBlock:^(id anyID, BOOL success) { 120 | NSLog(@"block值 确定 %@",anyID); 121 | }]; 122 | }else if([name isEqualToString:@"获取单例方法"]){ 123 | 124 | id URL = RouterURL().Singletarget_Actions(@"shareVC",@"shareInstance",@"shareAction2"); 125 | id param = RouterParam().selfParam(@{ 126 | @"key":@"2222", 127 | @"name":@"wmz3" 128 | }); 129 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 130 | 131 | }else if([name isEqualToString:@"错误处理跳转h5"]){ 132 | 133 | id URL = RouterURL().target(@"shareVC").action(@"错误方法"); 134 | id param = RouterParam().error(RouterPushH5); 135 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 136 | 137 | }else if ([name isEqualToString:@"网络请求测试成功(等待请求完回调)"]) { 138 | //netWork 传值不能为空 139 | 140 | id URL = RouterURL().target(@"netWorkTest").actions(@"netWorkSuccessTestWithSuccessWithParm"); 141 | id param = RouterParam().netWork(@""); 142 | 143 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param WithHandBlock:^(id anyID, BOOL success) { 144 | [[WMZAlert shareInstance] showAlertWithType:AlertTypeNornal textTitle:anyID]; 145 | }]; 146 | } 147 | else if ([name isEqualToString:@"网络请求测试失败"]) { 148 | //netWork 传值不能为空 149 | 150 | id URL = RouterURL().target(@"netWorkTest").actions(@"netWorkFailTestWithSuccessWithParm"); 151 | id param = RouterParam().netWork(@""); 152 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param WithHandBlock:^(id anyID, BOOL success) { 153 | [[WMZAlert shareInstance] showAlertWithType:AlertTypeNornal textTitle:anyID]; 154 | }]; 155 | }else if([name isEqualToString:@"错误处理自己处理"]){ 156 | 157 | id URL = RouterURL().target(@"shareVC").action(@"错误方法"); 158 | id param = RouterParam().dealSelfError(^(id anyID) { 159 | NSLog(@"获取到的 :%@",anyID); 160 | }); 161 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 162 | } 163 | } 164 | 165 | 166 | @end 167 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/LoginVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // LoginVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface LoginVC : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/LoginVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // LoginVC.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "LoginVC.h" 10 | 11 | @interface LoginVC () 12 | @property(nonatomic,strong)UITextField *moble; 13 | @property(nonatomic,strong)UITextField *password; 14 | @property(nonatomic,strong)UIButton *loginBtn; 15 | @property(nonatomic,strong)UIButton *reginBtn; 16 | @end 17 | 18 | @implementation LoginVC 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view 23 | 24 | [WMZUI newViewWithBackColor:[UIColor clearColor] WithSubView:self.view target:self action:@selector(emptyAction) Constraint:^(MASConstraintMaker *make) { 25 | make.edges.mas_equalTo(0); 26 | }]; 27 | 28 | self.moble = [WMZUI newTextFieldTextColor:nil Font:0 TextAlignment:0 Placeholder:@"请输入至少5位的手机号" KeyWord:UIKeyboardTypePhonePad WithSubView:self.view Constraint:^(MASConstraintMaker *make) { 29 | make.centerX.equalTo(self.view); 30 | make.centerY.equalTo(self.view).offset(-100); 31 | make.width.equalTo(self.view).multipliedBy(0.6); 32 | make.height.mas_equalTo(50); 33 | }]; 34 | self.moble.layer.borderColor = [UIColor cyanColor].CGColor; 35 | self.moble.layer.borderWidth = 0.5; 36 | 37 | 38 | self.password = [WMZUI newTextFieldTextColor:nil Font:0 TextAlignment:0 Placeholder:@"请输入至少3位的密码" KeyWord:0 WithSubView:self.view Constraint:^(MASConstraintMaker *make) { 39 | make.centerX.equalTo(self.view); 40 | make.top.equalTo(self.moble.mas_bottom).offset(20); 41 | make.width.equalTo(self.view).multipliedBy(0.6); 42 | make.height.mas_equalTo(50); 43 | }]; 44 | self.password.layer.borderColor = [UIColor cyanColor].CGColor; 45 | self.password.layer.borderWidth = 0.5; 46 | 47 | self.loginBtn = [WMZUI newButtonTitie:@"登录" TextColor:[UIColor orangeColor] SuperView:self.view target:self action:@selector(loginAction) Constraint:^(MASConstraintMaker *make) { 48 | make.left.equalTo(self.password.mas_left); 49 | make.width.equalTo(self.view).multipliedBy(0.25); 50 | make.height.mas_equalTo(40); 51 | make.top.equalTo(self.password.mas_bottom).offset(20); 52 | }]; 53 | 54 | 55 | self.reginBtn = [WMZUI newButtonTitie:@"(没账号)注册" TextColor:[UIColor orangeColor] SuperView:self.view target:self action:@selector(reginEnterAction) Constraint:^(MASConstraintMaker *make) { 56 | make.right.equalTo(self.password.mas_right); 57 | make.width.equalTo(self.view).multipliedBy(0.35); 58 | make.height.mas_equalTo(40); 59 | make.top.equalTo(self.password.mas_bottom).offset(20); 60 | }]; 61 | 62 | self.moble.text = @"13178864836"; 63 | self.password.text= @"123456"; 64 | 65 | 66 | } 67 | 68 | - (void)emptyAction{ 69 | [self.moble resignFirstResponder]; 70 | [self.password resignFirstResponder]; 71 | } 72 | 73 | //登录方法 74 | - (void)loginAction{ 75 | [self emptyAction]; 76 | 77 | WMZRouter *router = [WMZRouter shareInstance]; 78 | 79 | id checkURL = RouterURL().target_Actions(@"checkTool", @"checkLoginPhoneAndPassWordWithParam"); 80 | id checkParam = RouterParam().selfParam(@{ 81 | @"phone":self.moble.text, 82 | @"passWord":self.password.text, 83 | }); 84 | NSNumber *check = [router handleWithURL:checkURL WithParam:checkParam]; 85 | 86 | if (check&&check.boolValue) { 87 | //跳转VC 88 | id checkURL = RouterURL().target(@"getBaseTabVC"); 89 | id param = RouterParam().enterVCStyle(RouterRoot); 90 | //tabbar 需要自己跳转 91 | id VC = [router handleWithURL:checkURL WithParam:param]; 92 | [UIApplication sharedApplication].delegate.window.rootViewController = VC;; 93 | [[UIApplication sharedApplication].delegate.window makeKeyAndVisible]; 94 | 95 | } 96 | 97 | 98 | 99 | } 100 | 101 | //注册方法 102 | - (void)reginEnterAction{ 103 | 104 | id URL = RouterURL().target(@"getReginerVC"); 105 | id param = RouterParam().permissions(PermissionTypePhoto, ^(id anyID, BOOL success) { 106 | NSLog(@"%@",anyID); 107 | }).enterVCStyle(RouterPush).log(@"日志").cache(^(id anyID, BOOL success) { 108 | NSLog(@"缓存"); 109 | }).cacheTime(10).error(RouterPushFail).selfParam(@{}); 110 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 111 | 112 | } 113 | 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/MineVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // MineVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface MineVC : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/MineVC.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // 5 | // MineVC.m 6 | // WMZRouter 7 | // 8 | // Created by wmz on 2018/11/13. 9 | // Copyright © 2018年 wmz. All rights reserved. 10 | // 11 | 12 | #import "MineVC.h" 13 | 14 | @interface MineVC () 15 | @property(nonatomic,strong)WMZTableView *table; 16 | @end 17 | 18 | @implementation MineVC 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | WMZWeakSelf 24 | 25 | UIButton *cancelBtn = [WMZUI newButtonTitie:@"退出登录" TextColor:[UIColor whiteColor] BackColor:[UIColor orangeColor] WithFont:15 radio:10 SuperView:nil target:self action:@selector(cancelAction) Constraint:nil]; 26 | cancelBtn.frame = CGRectMake(30, 20, [UIScreen mainScreen].bounds.size.width-60, 50); 27 | 28 | self.table = [[WMZTableView shareGrouped] addTableViewWithType:CellTypeNornal withConstraint:^(MASConstraintMaker *make) { 29 | make.left.top.bottom.right.mas_equalTo(0); 30 | } withSuperView:self.view withData:@[@"修改资料"] withSection:1 withCellName:nil WithCellShow:^UITableViewCell *(id model, NSIndexPath *indexPath) { 31 | WMZRouterURL *URL = RouterURL().target(@"getNornalCell"); 32 | WMZRouterParam *param = RouterParam().CellTable(weakSelf.table); 33 | UITableViewCell *cell = [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 34 | //KVO赋值 35 | [cell setValue:model forKey:@"model"]; 36 | return cell; 37 | } WithCellCount:nil WithCellHeight:nil WithHeadHeight:^NSInteger(NSInteger section) { 38 | return 120; 39 | } WithFootHeight:^NSInteger(NSInteger section) { 40 | return 90; 41 | } WithHeadView:^UIView *(NSInteger section) { 42 | 43 | 44 | NSString *keyName = [NSString stringWithFormat:@"%@_%@",UserName,WMZObjectGet(UserPhone)]; 45 | NSString *keyAge = [NSString stringWithFormat:@"%@_%@",UserAge,WMZObjectGet(UserPhone)]; 46 | 47 | id URL = RouterURL().target(@"getView").actions(@"getHeadViewWithParma"); 48 | id param = RouterParam().permissions(PermissionTypePhoto, ^(id anyID, BOOL success) { 49 | NSLog(@"权限"); 50 | }).log(@"日志").selfParam(@{@"name":WMZObjectGet(keyName), 51 | @"detail":[NSString stringWithFormat:@"年龄:%@",WMZObjectGet(keyAge)] 52 | }); 53 | 54 | return [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 55 | 56 | } WithFootView:^UIView *(NSInteger section) { 57 | UIView *view = [UIView new]; 58 | view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 90); 59 | [view addSubview:cancelBtn]; 60 | return view; 61 | } Handle:^(id anyID) { 62 | [weakSelf doClick:anyID]; 63 | }]; 64 | 65 | } 66 | 67 | - (void)cancelAction{ 68 | id URL = RouterURL().target(@"getLoginVC"); 69 | id param = RouterParam().enterVCStyle(RouterRootNa); 70 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 71 | } 72 | 73 | - (void)doClick:(NSString*)name{ 74 | if (([name isEqualToString:@"修改资料"])){ 75 | id URL = RouterURL().target(@"getPersonVC"); 76 | id param = RouterParam().enterVCStyle(RouterPushHideTabBackShow); 77 | [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 78 | } 79 | } 80 | 81 | /* 82 | #pragma mark - Navigation 83 | 84 | // In a storyboard-based application, you will often want to do a little preparation before navigation 85 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 86 | // Get the new view controller using [segue destinationViewController]. 87 | // Pass the selected object to the new view controller. 88 | } 89 | */ 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/NewsVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewsVC.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseVC.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface NewsVC : BaseVC 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/VC/NewsVC.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // 5 | // NewsVC.m 6 | // WMZRouter 7 | // 8 | // Created by wmz on 2018/11/13. 9 | // Copyright © 2018年 wmz. All rights reserved. 10 | // 11 | 12 | #import "NewsVC.h" 13 | 14 | @interface NewsVC () 15 | @property(nonatomic,strong)WMZTableView *table; 16 | @end 17 | 18 | @implementation NewsVC 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | 24 | WMZWeakSelf 25 | self.table = [[WMZTableView sharePlain] addTableViewWithType:0 withConstraint:^(MASConstraintMaker *make) { 26 | make.left.top.bottom.right.mas_equalTo(0); 27 | } withSuperView:self.view withData:[self getData:@{@"count":@(200)}] WithCellShow:^UITableViewCell *(id model, NSIndexPath *indexPath) { 28 | 29 | WMZRouterURL *URL = RouterURL().target(@"getNewCell"); 30 | WMZRouterParam *param = RouterParam().CellTable(weakSelf.table); 31 | UITableViewCell *cell = [[WMZRouter shareInstance] handleWithURL:URL WithParam:param]; 32 | 33 | //KVO赋值 34 | if (model) { 35 | [cell setValue:model forKey:@"model"]; 36 | } 37 | return cell; 38 | } Handle:^(id anyID) { 39 | NSString *ID = [anyID valueForKey:@"ID"]; 40 | [[WMZRouter shareInstance] handleWithURL:@"getWebVC" WithParam: RouterParam().enterVCStyle(RouterPushHideTabBackShow).selfParam(@{ 41 | @"URL":[NSURL URLWithString:ID], 42 | @"btnShow":@(NO) 43 | })]; 44 | 45 | }]; 46 | 47 | 48 | 49 | } 50 | 51 | - (NSArray*)getData:(NSDictionary*)parm{ 52 | NSNumber *count = parm[@"count"]; 53 | NSMutableArray *modelArr = [NSMutableArray new]; 54 | for (int i = 0; i 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BaseCell : UITableViewCell 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/BaseCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseCell.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseCell.h" 10 | 11 | @implementation BaseCell 12 | 13 | + (NSString *)routerPath{ 14 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 15 | } 16 | 17 | - (void)awakeFromNib { 18 | [super awakeFromNib]; 19 | // Initialization code 20 | } 21 | 22 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 23 | [super setSelected:selected animated:animated]; 24 | 25 | // Configure the view for the selected state 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/BaseView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseView.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface BaseView : UIView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/BaseView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseView.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseView.h" 10 | 11 | @implementation BaseView 12 | 13 | + (NSString *)routerPath{ 14 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/NewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // NewCell.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/13. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseCell.h" 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface NewCell : BaseCell 13 | 14 | @property(nonatomic,strong)id model; 15 | 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/NewCell.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | // 7 | // NewCell.m 8 | // WMZRouter 9 | // 10 | // Created by wmz on 2018/11/13. 11 | // Copyright © 2018年 wmz. All rights reserved. 12 | // 13 | 14 | #import "NewCell.h" 15 | @interface NewCell() 16 | @property(nonatomic,strong)UILabel *title; 17 | 18 | @property(nonatomic,strong)UILabel *myLabel; 19 | 20 | @property(nonatomic,strong)UIImageView *icon; 21 | 22 | @property(nonatomic,strong)UILabel *time; 23 | 24 | 25 | @end 26 | @implementation NewCell 27 | 28 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 29 | 30 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 31 | self.backgroundColor = [UIColor whiteColor]; 32 | 33 | [self.contentView addSubview:self.icon]; 34 | [self.icon mas_makeConstraints:^(MASConstraintMaker *make) { 35 | make.left.equalTo(self.contentView).offset(20); 36 | make.top.equalTo(self.contentView).offset(20); 37 | make.width.height.mas_equalTo(80); 38 | }]; 39 | 40 | [self.contentView addSubview:self.title]; 41 | [self.title mas_makeConstraints:^(MASConstraintMaker *make) { 42 | make.left.equalTo(self.icon.mas_right).offset(20); 43 | make.top.equalTo(self.icon.mas_top).offset(5); 44 | make.right.equalTo(self.contentView.mas_right).offset(-20); 45 | }]; 46 | 47 | 48 | [self.contentView addSubview:self.myLabel]; 49 | [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) { 50 | make.left.equalTo(self.icon.mas_right).offset(20); 51 | make.top.equalTo(self.title.mas_bottom).offset(10); 52 | make.right.equalTo(self.contentView.mas_right).offset(-20); 53 | }]; 54 | 55 | [self.contentView addSubview:self.time]; 56 | [self.time mas_makeConstraints:^(MASConstraintMaker *make) { 57 | make.right.equalTo(self.contentView).offset(-20); 58 | make.top.equalTo(self.icon.mas_bottom).offset(20); 59 | make.bottom.equalTo(self.contentView).offset(-20); 60 | }]; 61 | 62 | [WMZUI newViewWithBackColor:[UIColor lightGrayColor] WithSubView:self.contentView Constraint:^(MASConstraintMaker *make) { 63 | make.left.right.bottom.mas_equalTo(0); 64 | make.height.mas_equalTo(0.5); 65 | }]; 66 | 67 | } 68 | return self; 69 | } 70 | 71 | - (UILabel *)myLabel{ 72 | if (!_myLabel) { 73 | _myLabel = [UILabel new]; 74 | _myLabel.numberOfLines = 2; 75 | _myLabel.textColor = [UIColor redColor]; 76 | 77 | } 78 | return _myLabel; 79 | } 80 | 81 | - (UILabel *)title{ 82 | if (!_title) { 83 | _title = [UILabel new]; 84 | _title.numberOfLines = 0; 85 | 86 | } 87 | return _title; 88 | } 89 | 90 | - (UILabel *)time{ 91 | if (!_time) { 92 | _time = [UILabel new]; 93 | _time.numberOfLines = 0; 94 | 95 | } 96 | return _time; 97 | } 98 | 99 | - (UIImageView *)icon{ 100 | if (!_icon) { 101 | _icon = [UIImageView new]; 102 | _icon.image = [UIImage imageNamed:@"6.jpg"]; 103 | } 104 | return _icon; 105 | } 106 | 107 | - (void)setModel:(id)model{ 108 | _model = model; 109 | self.title.text = [model valueForKey:@"title"]; 110 | self.myLabel.text = [model valueForKey:@"text"]; 111 | self.icon.image = [UIImage imageNamed:[model valueForKey:@"icon"]]; 112 | self.time.text = [model valueForKey:@"time"]; 113 | } 114 | 115 | - (void)awakeFromNib { 116 | [super awakeFromNib]; 117 | // Initialization code 118 | } 119 | 120 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 121 | [super setSelected:selected animated:animated]; 122 | 123 | // Configure the view for the selected state 124 | } 125 | 126 | + (NSString *)routerPath{ 127 | return [NSString stringWithFormat:@"get%@",NSStringFromClass([self class])]; 128 | } 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/ViewClass.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewClass.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/12. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "BaseView.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface ViewClass : BaseView 14 | 15 | - (UIView*)getInformationViewWithParma:(NSDictionary*)parma; 16 | 17 | - (UIView*)getHeadViewWithParma:(NSDictionary*)parma; 18 | 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /WMZRouter/Main(主要)/View/ViewClass.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // 5 | // ViewClass.m 6 | // WMZRouter 7 | // 8 | // Created by wmz on 2018/11/12. 9 | // Copyright © 2018年 wmz. All rights reserved. 10 | // 11 | 12 | #import "ViewClass.h" 13 | @interface ViewClass() 14 | @property(nonatomic,strong)UILabel *label; 15 | @end 16 | @implementation ViewClass 17 | 18 | - (UIView*)getInformationViewWithParma:(NSDictionary*)parma{ 19 | NSString *name = parma[@"name"]; 20 | NSString *detail = parma[@"detail"]; 21 | UIView *superView = parma[@"superView"]; 22 | NSInteger tag = [parma[@"tag"] integerValue]; 23 | if (!superView) { 24 | return self; 25 | } 26 | [superView addSubview:self]; 27 | self.tag = tag; 28 | UILabel *tip = [WMZUI newLabelText:name?[NSString stringWithFormat:@"%@ : ",name]:@" : " TextColor:nil SuperView:self Constraint:^(MASConstraintMaker *make) { 29 | make.left.mas_equalTo(20); 30 | make.centerY.equalTo(self); 31 | }]; 32 | 33 | 34 | [WMZUI newButtonTitie:@"-->" TextColor:[UIColor blackColor] SuperView:self target:nil action:nil Constraint:^(MASConstraintMaker *make) { 35 | make.height.equalTo(self); 36 | make.width.mas_equalTo(40); 37 | make.centerY.equalTo(self); 38 | make.right.mas_equalTo(-10); 39 | }]; 40 | 41 | self.label = [WMZUI newLabelText:detail?:@"" TextColor:[UIColor redColor] SuperView:self Constraint:^(MASConstraintMaker *make) { 42 | make.left.equalTo(tip.mas_right); 43 | make.centerY.equalTo(self); 44 | make.width.lessThanOrEqualTo(self).multipliedBy(0.5); 45 | }]; 46 | 47 | [WMZUI newViewAddTargetWithView:self target:self action:@selector(tapAction:)]; 48 | 49 | return self; 50 | } 51 | 52 | - (void)tapAction:(UITapGestureRecognizer*)tap{ 53 | UIView *view = tap.view; 54 | WMZWeakSelf 55 | if (view.tag==111) { 56 | [[WMZAlert shareInstance]showAlertWithType:AlertTypeWrite headTitle:@"昵称" textTitle:@"请输入昵称" leftHandle:^(id anyID) { 57 | 58 | } rightHandle:^(id anyID) { 59 | weakSelf.label.text = anyID; 60 | }]; 61 | }else if (view.tag==112) { 62 | [[WMZAlert shareInstance]showAlertWithType:AlertTypeWrite headTitle:@"年龄" textTitle:@"请输入年龄" leftHandle:^(id anyID) { 63 | 64 | } rightHandle:^(id anyID) { 65 | weakSelf.label.text = anyID; 66 | }]; 67 | }else if (view.tag==113) { 68 | [[WMZAlert shareInstance]showAlertWithType:AlertTypeSelect headTitle:@"婚否" textTitle:@[@"已婚",@"未婚"] leftHandle:^(id anyID) { 69 | 70 | } rightHandle:^(id anyID) { 71 | weakSelf.label.text = anyID; 72 | }]; 73 | } 74 | } 75 | 76 | - (UIView*)getHeadViewWithParma:(NSDictionary*)parma{ 77 | UIView *superView = parma[@"superView"]; 78 | NSString *name = parma[@"name"]; 79 | NSString *detail = parma[@"detail"]; 80 | self.backgroundColor = [UIColor redColor]; 81 | if (superView) { 82 | [superView addSubview:self]; 83 | } 84 | UIImageView *image = [WMZUI newImageViewWithName:@"0.png" WithSubView:self Constraint:^(MASConstraintMaker *make) { 85 | make.width.height.mas_equalTo(80); 86 | make.left.mas_equalTo(20); 87 | make.top.mas_equalTo(20); 88 | }]; 89 | image.backgroundColor = [UIColor redColor]; 90 | image.layer.masksToBounds = YES; 91 | image.layer.cornerRadius = 40; 92 | 93 | [WMZUI newLabelText:name TextColor:nil SuperView:self Constraint:^(MASConstraintMaker *make) { 94 | make.left.equalTo(image.mas_right).offset(20); 95 | make.top.equalTo(image.mas_top).offset(5); 96 | }]; 97 | 98 | [WMZUI newLabelText:detail TextColor:nil SuperView:self Constraint:^(MASConstraintMaker *make) { 99 | make.left.equalTo(image.mas_right).offset(20); 100 | make.bottom.equalTo(image.mas_bottom).offset(-5); 101 | }]; 102 | [self layoutIfNeeded]; 103 | self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, CGRectGetMaxY(image.frame)+20); 104 | return self; 105 | } 106 | 107 | + (NSString *)routerPath{ 108 | return @"getView"; 109 | } 110 | @end 111 | -------------------------------------------------------------------------------- /WMZRouter/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #ifndef PrefixHeader_pch 10 | #define PrefixHeader_pch 11 | 12 | 13 | // Include any system framework and library headers here that should be included in all compilation units. 14 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 15 | #import "Masonry.h" 16 | #import "WMZUI.h" 17 | #import "WMZRouter.h" 18 | #import "WMZRouter+Expand.h" 19 | #import "WMZAlert.h" 20 | #import "WMZTableView.h" 21 | #import "WMZCommon.h" 22 | #endif /* PrefixHeader_pch */ 23 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/Aspects.h: -------------------------------------------------------------------------------- 1 | // 2 | // Aspects.h 3 | // Aspects - A delightful, simple library for aspect oriented programming. 4 | // 5 | // Copyright (c) 2014 Peter Steinberger. Licensed under the MIT license. 6 | // 7 | 8 | #import 9 | 10 | typedef NS_OPTIONS(NSUInteger, AspectOptions) { 11 | AspectPositionAfter = 0, /// Called after the original implementation (default) 12 | AspectPositionInstead = 1, /// Will replace the original implementation. 13 | AspectPositionBefore = 2, /// Called before the original implementation. 14 | 15 | AspectOptionAutomaticRemoval = 1 << 3 /// Will remove the hook after the first execution. 16 | }; 17 | 18 | /// Opaque Aspect Token that allows to deregister the hook. 19 | @protocol AspectToken 20 | 21 | /// Deregisters an aspect. 22 | /// @return YES if deregistration is successful, otherwise NO. 23 | - (BOOL)remove; 24 | 25 | @end 26 | 27 | /// The AspectInfo protocol is the first parameter of our block syntax. 28 | @protocol AspectInfo 29 | 30 | /// The instance that is currently hooked. 31 | - (id)instance; 32 | 33 | /// The original invocation of the hooked method. 34 | - (NSInvocation *)originalInvocation; 35 | 36 | /// All method arguments, boxed. This is lazily evaluated. 37 | - (NSArray *)arguments; 38 | 39 | @end 40 | 41 | /** 42 | Aspects uses Objective-C message forwarding to hook into messages. This will create some overhead. Don't add aspects to methods that are called a lot. Aspects is meant for view/controller code that is not called a 1000 times per second. 43 | 44 | Adding aspects returns an opaque token which can be used to deregister again. All calls are thread safe. 45 | */ 46 | @interface NSObject (Aspects) 47 | 48 | /// Adds a block of code before/instead/after the current `selector` for a specific class. 49 | /// 50 | /// @param block Aspects replicates the type signature of the method being hooked. 51 | /// The first parameter will be `id`, followed by all parameters of the method. 52 | /// These parameters are optional and will be filled to match the block signature. 53 | /// You can even use an empty block, or one that simple gets `id`. 54 | /// 55 | /// @note Hooking static methods is not supported. 56 | /// @return A token which allows to later deregister the aspect. 57 | + (id)aspect_hookSelector:(SEL)selector 58 | withOptions:(AspectOptions)options 59 | usingBlock:(id)block 60 | error:(NSError **)error; 61 | 62 | /// Adds a block of code before/instead/after the current `selector` for a specific instance. 63 | - (id)aspect_hookSelector:(SEL)selector 64 | withOptions:(AspectOptions)options 65 | usingBlock:(id)block 66 | error:(NSError **)error; 67 | 68 | @end 69 | 70 | 71 | typedef NS_ENUM(NSUInteger, AspectErrorCode) { 72 | AspectErrorSelectorBlacklisted, /// Selectors like release, retain, autorelease are blacklisted. 73 | AspectErrorDoesNotRespondToSelector, /// Selector could not be found. 74 | AspectErrorSelectorDeallocPosition, /// When hooking dealloc, only AspectPositionBefore is allowed. 75 | AspectErrorSelectorAlreadyHookedInClassHierarchy, /// Statically hooking the same method in subclasses is not allowed. 76 | AspectErrorFailedToAllocateClassPair, /// The runtime failed creating a class pair. 77 | AspectErrorMissingBlockSignature, /// The block misses compile time signature info and can't be called. 78 | AspectErrorIncompatibleBlockSignature, /// The block signature does not match the method or is too large. 79 | 80 | AspectErrorRemoveObjectAlreadyDeallocated = 100 /// (for removing) The object hooked is already deallocated. 81 | }; 82 | 83 | extern NSString *const AspectErrorDomain; 84 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZBaseAop.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZBaseAop.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/26. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | //拦截器方法 10 | typedef enum : NSUInteger{ 11 | AopTypePermissions, //权限设置 12 | AopTypeCache, //数据缓存 13 | AopTypeLog, //日志打印 14 | AopTypeOpenURL, //打开URL 15 | AopTypespecialParameters, //VC跳转 16 | AopTypeClean, //清理handle 17 | AopTypeError, //错误处理 18 | AopTypeCell //错tableviewCell 19 | }AopActionType; 20 | 21 | 22 | #import 23 | 24 | @interface WMZBaseAop : NSObject 25 | 26 | /* 27 | * 初始化 28 | */ 29 | + (instancetype)shareInstance; 30 | 31 | /* 32 | * 添加拦截器 33 | */ 34 | - (void)addAopWithType:(AopActionType)type; 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZBaseAop.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZBaseAop.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/26. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | #import "WMZBaseAop.h" 9 | 10 | @implementation WMZBaseAop 11 | 12 | 13 | +(instancetype)shareInstance{ 14 | return [[self alloc]init]; 15 | } 16 | 17 | 18 | /* 19 | * 添加拦截器 20 | */ 21 | - (void)addAopWithType:(AopActionType)type{ 22 | switch (type) { 23 | case AopTypePermissions:{ 24 | [WMZRouter aspect_hookSelector:@selector(dealTarget:) withOptions:AspectPositionBefore|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 25 | { 26 | NSLog(@"权限设置开始"); 27 | } error:NULL]; 28 | } 29 | break; 30 | case AopTypeCache:{ 31 | [WMZRouter aspect_hookSelector:@selector(dealTarget:) withOptions:AspectPositionBefore|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 32 | { 33 | NSLog(@"数据缓存开始"); 34 | } error:NULL]; 35 | break; 36 | } 37 | case AopTypeLog:{ 38 | [WMZRouter aspect_hookSelector:@selector(dealTarget:) withOptions:AspectPositionBefore|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 39 | { 40 | NSLog(@"日志缓存开始"); 41 | } error:NULL]; 42 | break; 43 | } 44 | case AopTypeOpenURL:{ 45 | [WMZRouter aspect_hookSelector:@selector(dealTarget:) withOptions:AspectPositionBefore|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 46 | { 47 | NSLog(@"拦截非本app的方法作相应处理开始"); 48 | WMZRouter *route = aspectInfo.instance; 49 | [WMZRouter expandHandleOpenWithRequest:route.returnURL]; 50 | } error:NULL]; 51 | break; 52 | } 53 | case AopTypeCell:{ 54 | [WMZRouter aspect_hookSelector:@selector(analyze:withURL:) withOptions:AspectPositionBefore|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 55 | { 56 | NSLog(@"处理cell开始"); 57 | WMZRouter *route = aspectInfo.instance; 58 | [WMZRouter expandHandleTableViewCell:NSClassFromString(route.returnURL.target) WithRequest:route.returnURL]; 59 | } error:NULL]; 60 | break; 61 | } 62 | case AopTypespecialParameters:{ 63 | [WMZRouter aspect_hookSelector:@selector(handleWithURL:WithParam:WithHandBlock:) withOptions:AspectPositionAfter|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 64 | { 65 | WMZRouter *route = aspectInfo.instance; 66 | NSLog(@"跳转开始"); 67 | [WMZRouter expandHandleActionWithID:route.returnURL.returnValue WithRequest:route.returnURL]; 68 | } error:NULL]; 69 | break; 70 | } 71 | case AopTypeClean:{ 72 | [WMZRouter aspect_hookSelector:@selector(handleWithURL:WithParam:WithHandBlock:) withOptions:AspectPositionAfter|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 73 | { 74 | NSLog(@"定时清理 5分钟清理一次 开始"); 75 | [WMZRouter deleteLongUnUseHandleWithTarget:aspectInfo.instance]; 76 | } error:NULL]; 77 | break; 78 | } 79 | case AopTypeError:{ 80 | [WMZRouter aspect_hookSelector:@selector(handleWithURL:WithParam:WithHandBlock:) withOptions:AspectPositionAfter|AspectOptionAutomaticRemoval usingBlock:^(id aspectInfo) 81 | { 82 | NSLog(@"错误处理 开始"); 83 | WMZRouter *route = aspectInfo.instance; 84 | [WMZRouter expandHandleErrorWithRequest:route.returnURL]; 85 | } error:NULL]; 86 | break; 87 | } 88 | default: 89 | break; 90 | } 91 | } 92 | 93 | - (BOOL)remove{ 94 | return YES; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRequest.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | //处理URL格式 10 | typedef enum : NSUInteger{ 11 | TypeSelfAppAction, //调用本app的方法 12 | TypeOtherApp, //打开其他app 13 | TypeTell, //打电话 14 | TypeMailto, //打开邮箱 15 | TypeWeb, //打开外部浏览器网页 16 | }RouterHandleType; 17 | 18 | //handle URL或者传参 错误 19 | typedef enum : NSUInteger{ 20 | RouterSuccess, //正常 21 | RouterErrorFailURLError, //传入URL格式错误 22 | RouterErrorFailHandle, //注册handle失败 23 | RouterErrorFailAction, //找不到调用的方法 24 | RouterErrorFailInstance, //找不到调用的对象或者对象类型不符合要求 25 | RouterErrorFailPrama, //携带参数错误 26 | RouterErrorFailReturn //调用方法返回值错误 27 | }RouterError; 28 | 29 | //错误相对应处理 30 | typedef enum : NSUInteger{ 31 | RouterPushH5, //降级跳转h5 32 | RouterPushFail, //跳转到失败界面 33 | RouterUpdateRequire, //强制升级 34 | RouterUpdate, //不强制升级 35 | RouterBack //错误返回由使用者操作 36 | /* 37 | *。。。。。。。。。。。。。。。。。。。//自定义 38 | */ 39 | }RouterErrorAction; 40 | 41 | 42 | //VC跳转 43 | typedef enum : NSUInteger{ 44 | RouterPush, //push 45 | RouterPushHideTabBackShow, //push跳转过去先隐藏tabbar返回时显示tabbar 46 | RouterPushHideTab, //push跳转过去隐藏tabbar 47 | RouterPresent, //模态跳转 48 | RouterRoot, //设为当前window的根控制器 49 | RouterRootNa =6 //设为当前window的根控制器带导航栏 50 | }RouterVCPush; 51 | 52 | 53 | //权限类型 54 | typedef enum : NSUInteger{ 55 | PermissionTypeCamera, //相机权限 56 | PermissionTypeMic, //麦克风权限 57 | PermissionTypePhoto, //相册权限 58 | PermissionTypeLocationAll, //获取地理位置Always 59 | PermissionTypeLocationWhen, //获取地理位置When 60 | PermissionTypeCalendar, //日历 61 | PermissionTypeReminder, //Reminder 62 | PermissionTypeContacts //联系人 63 | }PermissionType; 64 | 65 | 66 | /* 67 | * 数据回调 68 | */ 69 | typedef void (^WMZRouterCallBlock)(id anyID,BOOL success); 70 | 71 | #import 72 | NS_ASSUME_NONNULL_BEGIN 73 | 74 | /* 75 | * 便捷式拼装URL 外部调用 76 | */ 77 | @interface WMZRouterURL :NSObject 78 | 79 | /* 80 | * 初始化 81 | */ 82 | WMZRouterURL * RouterURL(void); 83 | 84 | 85 | 86 | /* 87 | * 调用打开其他URL 88 | */ 89 | @property(nonatomic,copy,readonly) WMZRouterURL *(^openURL)(NSString* scheme); 90 | 91 | 92 | /* 93 | * 只调用对象 94 | */ 95 | @property(nonatomic,copy,readonly) WMZRouterURL *(^target)(NSString* _target); 96 | 97 | /* 98 | * 调用方法不带参数 99 | */ 100 | @property(nonatomic,copy,readonly) WMZRouterURL *(^action)(NSString* _action); 101 | 102 | /* 103 | * 调用方法带参数 104 | */ 105 | @property(nonatomic,copy,readonly) WMZRouterURL *(^actions)(NSString* _action); 106 | 107 | /* 108 | * 调用对象方法不带参数 109 | */ 110 | @property(nonatomic,copy,readonly) WMZRouterURL *(^target_Action)(NSString* _target,NSString* _action); 111 | 112 | 113 | /* 114 | * 调用单例方法不带参数 115 | */ 116 | @property(nonatomic,copy,readonly) WMZRouterURL *(^SingleTarget_Action)(NSString* _target,NSString* _shareInstance,NSString* _action); 117 | 118 | 119 | /* 120 | * 调用单例方法带参数 121 | */ 122 | @property(nonatomic,copy,readonly) WMZRouterURL *(^Singletarget_Actions)(NSString* _target,NSString* _shareInstance,NSString* _action); 123 | 124 | /* 125 | * 调用对象方法不带参数 126 | */ 127 | @property(nonatomic,copy,readonly) WMZRouterURL *(^target_Actions)(NSString* _target,NSString* _action); 128 | 129 | @property(nonatomic,copy)NSString *scheme; 130 | 131 | @property(nonatomic,copy)NSString *mTarget; 132 | 133 | @property(nonatomic,copy)NSString *mAction; 134 | 135 | @property(nonatomic,copy)NSString *shareInstance; 136 | 137 | @end 138 | 139 | 140 | //==================================================================================// 141 | //==================================================================================// 142 | //==================================================================================// 143 | 144 | /* 145 | * 此类为路由的对象 146 | */ 147 | @interface WMZRequest : NSObject 148 | /* 149 | * scheme 150 | */ 151 | @property(nonatomic,copy)NSString *scheme; 152 | 153 | /* 154 | * target 对象 155 | */ 156 | @property(nonatomic,copy)NSString *target; 157 | 158 | /* 159 | * 方法 160 | */ 161 | @property(nonatomic,copy)NSString *Expression; 162 | 163 | /* 164 | * 整个URL 165 | */ 166 | @property(nonatomic,copy)NSString *handURL; 167 | 168 | /* 169 | * 返回的值 170 | */ 171 | @property(nonatomic,strong)id returnValue; 172 | 173 | /* 174 | * handle type 175 | */ 176 | @property(nonatomic,assign)RouterHandleType type; 177 | 178 | /* 179 | * handle error type 180 | */ 181 | @property(nonatomic,assign)RouterError errorType; 182 | 183 | /* 184 | * block 185 | */ 186 | @property(nonatomic,copy)WMZRouterCallBlock block; 187 | 188 | /* 189 | * 参数 190 | */ 191 | @property(nonatomic,strong) NSDictionary* param; 192 | 193 | /* 194 | * 创建路由对象 195 | * @param URL 传入的URL 196 | * @param param 参数 197 | * @param block 回调 198 | * returm WMZRequest对象 199 | */ 200 | + (WMZRequest*)handldWithURL:(id)URL withParm:(id)parm withBlock:(WMZRouterCallBlock)block; 201 | 202 | 203 | 204 | @end 205 | 206 | 207 | 208 | 209 | NS_ASSUME_NONNULL_END 210 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRequest.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZRequest.h" 10 | 11 | @implementation WMZRouterURL 12 | 13 | + (instancetype)Instance{ 14 | return [[self alloc] init]; 15 | } 16 | 17 | - (WMZRouterURL *(^)(NSString*))openURL{ 18 | return ^WMZRouterURL*(NSString* scheme){ 19 | self.scheme = scheme; 20 | return self; 21 | }; 22 | } 23 | 24 | - (WMZRouterURL *(^)(NSString*))target{ 25 | return ^WMZRouterURL*(NSString* _target){ 26 | self.mTarget = _target; 27 | return self; 28 | }; 29 | } 30 | 31 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull))action{ 32 | return ^WMZRouterURL*(NSString* _action){ 33 | self.mAction = _action; 34 | return self; 35 | }; 36 | } 37 | 38 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull))actions{ 39 | return ^WMZRouterURL*(NSString* _action){ 40 | self.mAction = [NSString stringWithFormat:@"%@:",_action]; 41 | return self; 42 | }; 43 | } 44 | 45 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull, NSString * _Nonnull))target_Action{ 46 | return ^WMZRouterURL*(NSString* _target,NSString* _action){ 47 | self.mTarget = _target; 48 | self.mAction = _action; 49 | return self; 50 | }; 51 | } 52 | 53 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull, NSString * _Nonnull))target_Actions{ 54 | return ^WMZRouterURL*(NSString* _target,NSString* _action){ 55 | self.mTarget = _target; 56 | self.mAction = [NSString stringWithFormat:@"%@:",_action]; 57 | return self; 58 | }; 59 | } 60 | 61 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull, NSString * _Nonnull, NSString * _Nonnull))SingleTarget_Action{ 62 | return ^WMZRouterURL*(NSString* _target,NSString* _shareInstance,NSString* _action){ 63 | self.mTarget = _target; 64 | self.shareInstance = _shareInstance; 65 | self.mAction = [NSString stringWithFormat:@"%@",_action]; 66 | return self; 67 | }; 68 | } 69 | 70 | - (WMZRouterURL * _Nonnull (^)(NSString * _Nonnull, NSString * _Nonnull, NSString * _Nonnull))Singletarget_Actions{ 71 | return ^WMZRouterURL*(NSString* _target,NSString* _shareInstance,NSString* _action){ 72 | self.mTarget = _target; 73 | self.shareInstance = _shareInstance; 74 | self.mAction = [NSString stringWithFormat:@"%@:",_action]; 75 | return self; 76 | }; 77 | } 78 | 79 | WMZRouterURL * RouterURL(void){ 80 | return [WMZRouterURL Instance]; 81 | } 82 | 83 | @end 84 | 85 | 86 | //==================================================================================// 87 | //==================================================================================// 88 | //==================================================================================// 89 | 90 | 91 | 92 | @implementation WMZRequest 93 | 94 | /* 95 | * 创建路由对象 96 | * @param URL 传入的URL 97 | * @param param 参数 98 | * @param block 回调 99 | * returm WMZRequest对象 100 | */ 101 | + (WMZRequest*)handldWithURL:(id)URL withParm:(id)parm withBlock:(WMZRouterCallBlock)block{ 102 | WMZRequest *request = [WMZRequest new]; 103 | //只能传字符串类型和WMZRouterURL类型 104 | if (!URL||(![URL isKindOfClass:[NSString class]]&&![URL isKindOfClass:[WMZRouterURL class]])) { 105 | return request; 106 | } 107 | request.block = block; 108 | if ([parm isKindOfClass:[WMZRouterParam class]]) { 109 | WMZRouterParam *tempParam = (WMZRouterParam*)parm; 110 | request.param = [NSDictionary dictionaryWithDictionary:tempParam.routerDic]; 111 | }else if([parm isKindOfClass:[NSDictionary class]]||[parm isKindOfClass:[NSMutableDictionary class]]){ 112 | request.param = [NSDictionary dictionaryWithDictionary:parm]; 113 | }else{ 114 | request.param = parm; 115 | } 116 | 117 | 118 | if (block&&request.param[@"netWork"]) { 119 | NSMutableDictionary *mdic = [NSMutableDictionary dictionaryWithDictionary:request.param]; 120 | [mdic setObject:request.block forKey:@"block"]; 121 | request.param = [NSDictionary dictionaryWithDictionary:mdic]; 122 | 123 | } 124 | 125 | if ([URL isKindOfClass:[NSString class]]) { 126 | NSRange range = [URL rangeOfString:@"://"]; 127 | NSString *tagetAndExpression = URL; 128 | if (range.location != NSNotFound) { 129 | request.scheme = [URL substringWithRange:NSMakeRange(0,range.location)]; 130 | tagetAndExpression = [URL substringFromIndex:range.length+range.location]; 131 | } 132 | 133 | if ([tagetAndExpression containsString:@"/"]) { 134 | NSArray *arr = [tagetAndExpression componentsSeparatedByString:@"/"]; 135 | 136 | if (arr.count>0) { 137 | if (WMZBoolNill(arr[0])) { 138 | request.target = arr[0]; 139 | } 140 | NSString *string = nil; 141 | if (arr.count==2) { 142 | string = arr[1]; 143 | }else { 144 | NSMutableString *mString = [NSMutableString new]; 145 | for (int i = 1; i 9 | #import 10 | #import 11 | #import "WMZRequest.h" 12 | #import "WMZRouterParam.h" 13 | #import "WMZRouterProtocol.h" 14 | #import "Aspects.h" 15 | #import "WMZBaseAop.h" 16 | 17 | 18 | @interface WMZRouteBase : NSObject 19 | 20 | /* 21 | * 初始化 22 | */ 23 | + (instancetype)shareInstance; 24 | 25 | 26 | 27 | /* 28 | * 调用方法修改返回值 29 | * @param action 方法名 30 | * @param URL 路由对象 31 | * @param target target 32 | * @param dic 所带参数 33 | * returm id 返回值 34 | */ 35 | + (id)performIDSelector:(SEL)action withObjects:(WMZRequest*)URL Tagert:(id)target withParm:(id)dic; 36 | 37 | /* 38 | * 获取当前VC 39 | */ 40 | + (UIViewController *)getCurrentVC; 41 | 42 | 43 | /* 44 | * 处理路由对象 (不做外部调用/添加拦截器时使用) 45 | * @param myURL 路由对象 46 | */ 47 | - (void)dealTarget:(WMZRequest*)myURL; 48 | 49 | 50 | /* 51 | * 处理获取到的类 (不做外部调用/添加拦截器时使用) 52 | * @param className 类 53 | * @param myURL 路由对象 54 | */ 55 | - (void)analyze:(Class)className withURL:(WMZRequest*)myURL; 56 | 57 | 58 | /* 59 | * 判断多方法还是单一方法,实例方法或者类方法调用(不做外部调用/添加拦截器时使用) 60 | * @param className 类 61 | * @param myURL 路由对象 62 | */ 63 | - (void)performSeleectWithClass:(Class)className withURL:(WMZRequest*)myURL; 64 | 65 | 66 | /* 67 | * 执行方法(不做外部调用/添加拦截器时使用) 68 | * @param className 类名 69 | * @param actionName 方法名 70 | * @param myURL 路由对象 71 | */ 72 | - (void)actionStart:(Class)className actionName:(NSString*)actionName withURL:(WMZRequest*)myURL; 73 | 74 | 75 | 76 | @end 77 | 78 | 79 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouteBase.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouteBase.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/16. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZRouteBase.h" 10 | @implementation WMZRouteBase 11 | static WMZRouteBase *_instance; 12 | /* 13 | * 单例 14 | */ 15 | +(instancetype)shareInstance{ 16 | static dispatch_once_t onceToken ; 17 | dispatch_once(&onceToken, ^{ 18 | _instance = [[super allocWithZone:NULL] init]; 19 | }) ; 20 | return _instance; 21 | } 22 | 23 | +(id) allocWithZone:(struct _NSZone *)zone 24 | { 25 | return [WMZRouteBase shareInstance] ; 26 | } 27 | 28 | -(id) copyWithZone:(struct _NSZone *)zone 29 | { 30 | return [WMZRouteBase shareInstance] ; 31 | } 32 | 33 | 34 | 35 | /* 36 | * 处理路由对象 (不做外部调用/添加拦截器时使用) 37 | * @param myURL 路由对象 38 | */ 39 | - (void)dealTarget:(WMZRequest*)myURL{} 40 | 41 | /* 42 | * 处理获取到的类 (不做外部调用/添加拦截器时使用) 43 | * @param className 类名 44 | * @param myURL 路由对象 45 | */ 46 | - (void)analyze:(Class)className withURL:(WMZRequest*)myURL{} 47 | 48 | /* 49 | * 判断多方法还是单一方法,实例方法或者类方法调用(不做外部调用/添加拦截器时使用) 50 | * @param className 类名 51 | * @param myURL 路由对象 52 | */ 53 | - (void)performSeleectWithClass:(Class)className withURL:(WMZRequest*)myUR{} 54 | 55 | 56 | /* 57 | * 执行方法(不做外部调用/添加拦截器时使用) 58 | * @param className 类名 59 | * @param actionName 方法名 60 | * @param myURL 路由对象 61 | */ 62 | - (void)actionStart:(Class)className actionName:(NSString*)actionName withURL:(WMZRequest*)myURL{} 63 | 64 | 65 | /* 66 | * 调用方法修改返回值 67 | * @param action 方法名 68 | * @param URL 路由对象 69 | * @param target target 70 | * @param dic 所带参数 71 | * returm id 返回值 72 | */ 73 | + (id)performIDSelector:(SEL)action withObjects:(WMZRequest*)URL Tagert:(id)target withParm:(id)dic{ 74 | id params = dic; 75 | NSMethodSignature *methodSig = [target methodSignatureForSelector:action]; 76 | if(methodSig == nil) 77 | { 78 | URL.errorType = RouterErrorFailAction; 79 | return nil; 80 | } 81 | else 82 | { 83 | URL.errorType = RouterSuccess; 84 | const char* retType = [methodSig methodReturnType]; 85 | 86 | if (strcmp(retType, @encode(void)) == 0) { 87 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 88 | if (params) { 89 | if ([params isKindOfClass:[NSDictionary class]]) { 90 | if ([[params allKeys] count]>0) { 91 | [invocation setArgument:¶ms atIndex:2]; 92 | } 93 | }else{ 94 | [invocation setArgument:¶ms atIndex:2]; 95 | } 96 | } 97 | [invocation setSelector:action]; 98 | [invocation setTarget:target]; 99 | [invocation invoke]; 100 | return nil; 101 | } 102 | 103 | if (strcmp(retType, @encode(NSInteger)) == 0) { 104 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 105 | if (params) { 106 | if ([params isKindOfClass:[NSDictionary class]]) { 107 | if ([[params allKeys] count]>0) { 108 | [invocation setArgument:¶ms atIndex:2]; 109 | } 110 | }else{ 111 | [invocation setArgument:¶ms atIndex:2]; 112 | } 113 | } 114 | [invocation setSelector:action]; 115 | [invocation setTarget:target]; 116 | [invocation invoke]; 117 | NSInteger result = 0; 118 | [invocation getReturnValue:&result]; 119 | return @(result); 120 | } 121 | 122 | if (strcmp(retType, @encode(BOOL)) == 0) { 123 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 124 | if (params) { 125 | if ([params isKindOfClass:[NSDictionary class]]) { 126 | if ([[params allKeys] count]>0) { 127 | [invocation setArgument:¶ms atIndex:2]; 128 | } 129 | }else{ 130 | [invocation setArgument:¶ms atIndex:2]; 131 | } 132 | } 133 | [invocation setSelector:action]; 134 | [invocation setTarget:target]; 135 | [invocation invoke]; 136 | BOOL result = 0; 137 | [invocation getReturnValue:&result]; 138 | return @(result); 139 | } 140 | 141 | if (strcmp(retType, @encode(CGFloat)) == 0) { 142 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 143 | if (params) { 144 | if ([params isKindOfClass:[NSDictionary class]]) { 145 | if ([[params allKeys] count]>0) { 146 | [invocation setArgument:¶ms atIndex:2]; 147 | } 148 | }else{ 149 | [invocation setArgument:¶ms atIndex:2]; 150 | } 151 | } 152 | [invocation setSelector:action]; 153 | [invocation setTarget:target]; 154 | [invocation invoke]; 155 | CGFloat result = 0; 156 | [invocation getReturnValue:&result]; 157 | return @(result); 158 | } 159 | 160 | if (strcmp(retType, @encode(double)) == 0) { 161 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; 162 | if (params) { 163 | if ([params isKindOfClass:[NSDictionary class]]) { 164 | if ([[params allKeys] count]>0) { 165 | [invocation setArgument:¶ms atIndex:2]; 166 | } 167 | }else{ 168 | [invocation setArgument:¶ms atIndex:2]; 169 | } 170 | } 171 | [invocation setSelector:action]; 172 | [invocation setTarget:target]; 173 | [invocation invoke]; 174 | NSUInteger result = 0; 175 | [invocation getReturnValue:&result]; 176 | return @(result); 177 | } 178 | } 179 | #pragma clang diagnostic push 180 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 181 | return [target performSelector:action withObject:params]; 182 | #pragma clang diagnostic pop 183 | } 184 | 185 | /* 186 | * 获取当前VC 187 | */ 188 | + (UIViewController *)getCurrentVC 189 | { 190 | UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; 191 | UIViewController *currentVC = [self getCurrentVCFrom:rootViewController]; 192 | return currentVC; 193 | } 194 | 195 | + (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC 196 | { 197 | UIViewController *currentVC; 198 | if ([rootVC presentedViewController]) { 199 | rootVC = [rootVC presentedViewController]; 200 | } 201 | if ([rootVC isKindOfClass:[UITabBarController class]]) { 202 | currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]]; 203 | } else if ([rootVC isKindOfClass:[UINavigationController class]]){ 204 | currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]]; 205 | } else { 206 | currentVC = rootVC; 207 | } 208 | return currentVC; 209 | } 210 | 211 | 212 | @end 213 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouter+Expand.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouter+Expand.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/26. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZRouter.h" 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | /* 13 | *路由的拓展工具类 14 | */ 15 | @interface WMZRouter (Expand) 16 | /* 17 | * 处理路由的错误 18 | * @param request 路由对象 19 | * returm Bool 有无block返回 20 | */ 21 | + (BOOL)expandHandleErrorWithRequest:(WMZRequest*)request; 22 | 23 | /* 24 | * 路由扩展VC跳转 25 | * @param instance 组件 26 | * @param request 路由对象 27 | */ 28 | + (void)expandHandleActionWithID:(id)instance WithRequest:(WMZRequest*)request; 29 | 30 | 31 | /* 32 | * 路由扩展打开其他URL 33 | * @param request 路由对象 34 | */ 35 | + (void)expandHandleOpenWithRequest:(WMZRequest*)request; 36 | 37 | 38 | /* 39 | * 获取tableviewCell 40 | * @param instance class 41 | * @param request 路由对象 42 | * returm id 任意类型 43 | */ 44 | + (id)expandHandleTableViewCell:(Class)instance WithRequest:(WMZRequest*)request; 45 | 46 | /* 47 | * 调用方法 48 | * @param action 方法名 49 | * @param params 所带参数 50 | * returm target target 51 | */ 52 | + (void)deleteLongUnUseHandleWithTarget:(id)instance; 53 | 54 | 55 | /* 56 | * 判断两个时间间隔 57 | * @param startDate 厨师时间 58 | * @param toDate 比较的时间 59 | * @param deleteTime 间隔的时间 60 | * returm BOOL 结果 61 | */ 62 | + (BOOL)compareDate:(NSDate*)startDate WithToDate:(NSDate*)toDate withSecond:(NSInteger)deleteTime; 63 | 64 | 65 | @end 66 | 67 | NS_ASSUME_NONNULL_END 68 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouter.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouter.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZRouteBase.h" 10 | @interface WMZRouter : WMZRouteBase 11 | 12 | /* 13 | *路由存放handle字典 14 | */ 15 | @property(nonatomic,strong) NSMutableDictionary *handleDic; 16 | 17 | /* 18 | *返回对象 19 | */ 20 | @property(nonatomic,strong) WMZRequest *returnURL; 21 | 22 | /* 23 | *路由其他拓展操作字典 24 | */ 25 | @property(nonatomic,strong) NSMutableDictionary *expandDic; 26 | 27 | /* 28 | * 路由调用方法带block 29 | * @param URLString URL URL格式为 (scheme/)target/expressin(/other) 30 | * @param param 参数 特殊参数见说明文档 31 | * @param dataBlock block (处理网络请求 弹窗等需要操作或者延时的操作使用) 32 | * returm 任意类型 33 | */ 34 | - (id)handleWithURL:(id)URLString WithParam:(id)param WithHandBlock:(WMZRouterCallBlock)dataBlock; 35 | 36 | /* 37 | * 路由调用方法不带block 38 | * @param URLString URL URL格式为 (scheme/)target/expressin(/other) 39 | * @param param 参数 特殊参数见说明文档 40 | * returm 任意类型 41 | */ 42 | - (id)handleWithURL:(id)URLString WithParam:(id)param; 43 | 44 | @end 45 | 46 | 47 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouterParam.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterParam.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/27. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /* 12 | * 处理 13 | */ 14 | typedef void (^WMZDealCallBlock)(id anyID); 15 | 16 | 17 | @interface WMZRouterParam : NSObject 18 | 19 | /* 20 | * 初始化 21 | */ 22 | + (instancetype)Instance; 23 | 24 | /* 25 | * 初始化 26 | */ 27 | WMZRouterParam * RouterParam(void); 28 | 29 | /* 30 | * 拼接起来的字典(外部无需调用) 31 | */ 32 | @property(nonatomic,strong)NSMutableDictionary *routerDic; 33 | 34 | // =========================================要传递过去的参数============================================== 35 | 36 | /* 37 | * 传递的参数 38 | */ 39 | @property(nonatomic,copy,readonly) WMZRouterParam *(^selfParam)(NSDictionary *selfParam); 40 | 41 | 42 | // =========================================系统参数===================================================== 43 | 44 | /* 45 | * 权限设置 46 | */ 47 | @property(nonatomic,copy,readonly) WMZRouterParam *(^permissions)(PermissionType type,WMZRouterCallBlock callBack); 48 | 49 | /* 50 | * 数据缓存 51 | */ 52 | @property(nonatomic,copy,readonly) WMZRouterParam *(^cache)(WMZRouterCallBlock callBack); 53 | 54 | /* 55 | * 数据缓存时间 56 | */ 57 | @property(nonatomic,copy,readonly) WMZRouterParam *(^cacheTime)(NSInteger time); 58 | 59 | /* 60 | * 日志记录 61 | */ 62 | @property(nonatomic,copy,readonly) WMZRouterParam *(^log)(id log); 63 | 64 | 65 | // =========================================特殊参数参数===================================================== 66 | 67 | /* 68 | * 跳转方式 69 | */ 70 | @property(nonatomic,copy,readonly) WMZRouterParam *(^enterVCStyle)(RouterVCPush type); 71 | 72 | 73 | /* 74 | * 打开URL 75 | */ 76 | @property(nonatomic,copy,readonly) WMZRouterParam *(^openURL)(void); 77 | 78 | 79 | /* 80 | * 错误系统处理 81 | */ 82 | @property(nonatomic,copy,readonly) WMZRouterParam *(^error)(RouterErrorAction type); 83 | 84 | /* 85 | * 错误自己处理 86 | */ 87 | @property(nonatomic,copy,readonly) WMZRouterParam *(^dealSelfError)(WMZDealCallBlock block); 88 | 89 | 90 | /* 91 | * tableViewCell 92 | */ 93 | @property(nonatomic,copy,readonly) WMZRouterParam *(^CellTable)(UITableView *CellTable); 94 | 95 | /* 96 | * 网络请求 97 | */ 98 | @property(nonatomic,copy,readonly) WMZRouterParam *(^netWork)(id netWork); 99 | 100 | 101 | @end 102 | 103 | 104 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouterParam.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterParam.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/27. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import "WMZRouterParam.h" 10 | 11 | @interface WMZRouterParam () 12 | @property(nonatomic,strong)WMZBaseAop *aop; 13 | @end 14 | @implementation WMZRouterParam 15 | 16 | + (instancetype)Instance{ 17 | return [[self alloc]init]; 18 | } 19 | 20 | /* 21 | * 初始化 22 | */ 23 | WMZRouterParam *RouterParam(void){ 24 | return [WMZRouterParam Instance]; 25 | } 26 | 27 | /* 28 | * 传递的参数 29 | */ 30 | - (WMZRouterParam *(^)(NSDictionary *))selfParam{ 31 | return ^WMZRouterParam*(NSDictionary* selfParam){ 32 | [selfParam enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { 33 | if (obj) { 34 | [self.routerDic setObject:obj forKey:key]; 35 | } 36 | }]; 37 | return self; 38 | }; 39 | } 40 | 41 | 42 | /* 43 | * 权限设置 44 | */ 45 | - (WMZRouterParam *(^)(PermissionType, WMZRouterCallBlock))permissions{ 46 | return ^WMZRouterParam*(PermissionType type,WMZRouterCallBlock block){ 47 | [self.aop addAopWithType:AopTypePermissions]; 48 | return self; 49 | }; 50 | } 51 | 52 | /* 53 | * 数据缓存 54 | */ 55 | - (WMZRouterParam *(^)(WMZRouterCallBlock))cache{ 56 | return ^WMZRouterParam*(WMZRouterCallBlock cacheBlock){ 57 | [self.aop addAopWithType:AopTypeCache]; 58 | if (cacheBlock) { 59 | cacheBlock(@"缓存数据",YES); 60 | } 61 | return self; 62 | }; 63 | } 64 | 65 | /* 66 | * 数据缓存时间 67 | */ 68 | - (WMZRouterParam *(^)(NSInteger))cacheTime{ 69 | return ^WMZRouterParam*(NSInteger cacheTime){ 70 | // 71 | return self; 72 | }; 73 | } 74 | 75 | 76 | /* 77 | * 日志记录 78 | */ 79 | - (WMZRouterParam *(^)(id))log{ 80 | return ^WMZRouterParam*(id log){ 81 | [self.aop addAopWithType:AopTypeLog]; 82 | return self; 83 | }; 84 | } 85 | 86 | 87 | 88 | /* 89 | * 跳转方式 90 | */ 91 | - (WMZRouterParam *(^)(RouterVCPush))enterVCStyle{ 92 | return ^WMZRouterParam*(RouterVCPush type){ 93 | [self.aop addAopWithType:AopTypespecialParameters]; 94 | [self.routerDic setObject:@(type) forKey:@"enterVCStyle"]; 95 | return self; 96 | }; 97 | } 98 | 99 | /* 100 | * 打开URL 101 | */ 102 | - (WMZRouterParam *(^)(void))openURL{ 103 | return ^WMZRouterParam*(){ 104 | [self.aop addAopWithType:AopTypeOpenURL]; 105 | return self; 106 | }; 107 | } 108 | 109 | /* 110 | * 错误系统处理 111 | */ 112 | - (WMZRouterParam *(^)(RouterErrorAction))error{ 113 | return ^WMZRouterParam*(RouterErrorAction type){ 114 | [self.aop addAopWithType:AopTypeError]; 115 | [self.routerDic setObject:@(type) forKey:@"error"]; 116 | return self; 117 | }; 118 | } 119 | 120 | 121 | /* 122 | * 错误自己处理 123 | */ 124 | - (WMZRouterParam *(^)(WMZDealCallBlock))dealSelfError{ 125 | return ^WMZRouterParam*(WMZDealCallBlock block){ 126 | [self.aop addAopWithType:AopTypeError]; 127 | [self.routerDic setObject:@(RouterBack) forKey:@"error"]; 128 | if (block) { 129 | [self.routerDic setObject:block forKey:@"errorBlock"]; 130 | } 131 | return self; 132 | }; 133 | } 134 | 135 | /* 136 | * tableViewCell 137 | */ 138 | - (WMZRouterParam *(^)(UITableView *))CellTable{ 139 | return ^WMZRouterParam*(UITableView* CellTable){ 140 | [self.aop addAopWithType:AopTypeCell]; 141 | [self.routerDic setObject:CellTable forKey:@"CellTable"]; 142 | return self; 143 | }; 144 | } 145 | 146 | /* 147 | * 网络请求 148 | */ 149 | - (WMZRouterParam *(^)(id))netWork{ 150 | return ^WMZRouterParam*(id netWork){ 151 | [self.routerDic setObject:netWork forKey:@"netWork"]; 152 | return self; 153 | }; 154 | } 155 | 156 | - (NSMutableDictionary *)routerDic{ 157 | if (!_routerDic) { 158 | _routerDic = [NSMutableDictionary new]; 159 | } 160 | return _routerDic; 161 | } 162 | 163 | - (WMZBaseAop *)aop{ 164 | if (!_aop) { 165 | _aop = [WMZBaseAop shareInstance]; 166 | } 167 | return _aop; 168 | } 169 | 170 | @end 171 | -------------------------------------------------------------------------------- /WMZRouter/WMZRouter/WMZRouterProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterProtocol.h 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/20. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /* 12 | * 协议 (要成为handle必须实现该协议和协议的方法) 13 | */ 14 | @protocol WMZRouterProtocol 15 | 16 | @required 17 | /* 18 | * 协议 (调用时的target要与此实现方法的返回值相同) 19 | */ 20 | + (NSString*)routerPath; 21 | 22 | @end 23 | 24 | 25 | ///* 26 | // * 协议 (拦截器协议) 27 | // */ 28 | //@protocol WMZRouterAopProtocol 29 | // 30 | //@optional 31 | // 32 | ///* 33 | // * 是否开启系统拦截方法(实例类调用无效 路由的扩展框架调用) 34 | // */ 35 | //+ (BOOL)openSystemAop; 36 | // 37 | ///* 38 | // * 系统拦截器数组 (实例类调用无效 路由的扩展框架调用) 39 | // */ 40 | //+ (NSArray*)systemAopArr; 41 | // 42 | // 43 | ///* 44 | // * 前拦截器数组 (实例类调用) 45 | // */ 46 | //+ (NSArray*)beforeAopArr; 47 | // 48 | // 49 | ///* 50 | // * 后拦截器数组 (实例类调用) 51 | // */ 52 | //+ (NSArray*)afterAopArr; 53 | // 54 | //@end 55 | -------------------------------------------------------------------------------- /WMZRouter/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WMZRouter 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. 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 | -------------------------------------------------------------------------------- /WMZRouterTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZRouterTests/WMZRouterTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterTests.m 3 | // WMZRouterTests 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZRouterTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZRouterTests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | } 20 | 21 | - (void)tearDown { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | // Use XCTAssert and related functions to verify your tests produce the correct results. 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /WMZRouterUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WMZRouterUITests/WMZRouterUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WMZRouterUITests.m 3 | // WMZRouterUITests 4 | // 5 | // Created by wmz on 2018/11/8. 6 | // Copyright © 2018年 wmz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WMZRouterUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WMZRouterUITests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | 20 | // In UI tests it is usually best to stop immediately when a failure occurs. 21 | self.continueAfterFailure = NO; 22 | 23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 24 | [[[XCUIApplication alloc] init] launch]; 25 | 26 | // 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. 27 | } 28 | 29 | - (void)tearDown { 30 | // Put teardown code here. This method is called after the invocation of each test method in the class. 31 | } 32 | 33 | - (void)testExample { 34 | // Use recording to get started writing UI tests. 35 | // Use XCTAssert and related functions to verify your tests produce the correct results. 36 | } 37 | 38 | @end 39 | --------------------------------------------------------------------------------