├── MainProject
├── MainProject.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── MainProject.xcscmblueprint
├── MainProject.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── MainProject.xcscmblueprint
├── MainProject
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── HomeViewController.h
│ ├── HomeViewController.m
│ ├── Info.plist
│ ├── LoginViewController.h
│ ├── LoginViewController.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── Podfile
├── Podfile.lock
└── Pods
│ ├── Headers
│ ├── Private
│ │ ├── HomePageModule
│ │ │ ├── HomePageModule.h
│ │ │ └── HomePageViewController.h
│ │ ├── MGJRouter
│ │ │ └── MGJRouter.h
│ │ ├── Masonry
│ │ │ ├── MASCompositeConstraint.h
│ │ │ ├── MASConstraint+Private.h
│ │ │ ├── MASConstraint.h
│ │ │ ├── MASConstraintMaker.h
│ │ │ ├── MASLayoutConstraint.h
│ │ │ ├── MASUtilities.h
│ │ │ ├── MASViewAttribute.h
│ │ │ ├── MASViewConstraint.h
│ │ │ ├── Masonry.h
│ │ │ ├── NSArray+MASAdditions.h
│ │ │ ├── NSArray+MASShorthandAdditions.h
│ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h
│ │ │ ├── View+MASAdditions.h
│ │ │ ├── View+MASShorthandAdditions.h
│ │ │ └── ViewController+MASAdditions.h
│ │ └── UserCenterModule
│ │ │ ├── UserCenterModule.h
│ │ │ └── UserCenterViewController.h
│ └── Public
│ │ ├── HomePageModule
│ │ ├── HomePageModule.h
│ │ └── HomePageViewController.h
│ │ ├── MGJRouter
│ │ └── MGJRouter.h
│ │ ├── Masonry
│ │ ├── MASCompositeConstraint.h
│ │ ├── MASConstraint+Private.h
│ │ ├── MASConstraint.h
│ │ ├── MASConstraintMaker.h
│ │ ├── MASLayoutConstraint.h
│ │ ├── MASUtilities.h
│ │ ├── MASViewAttribute.h
│ │ ├── MASViewConstraint.h
│ │ ├── Masonry.h
│ │ ├── NSArray+MASAdditions.h
│ │ ├── NSArray+MASShorthandAdditions.h
│ │ ├── NSLayoutConstraint+MASDebugAdditions.h
│ │ ├── View+MASAdditions.h
│ │ ├── View+MASShorthandAdditions.h
│ │ └── ViewController+MASAdditions.h
│ │ └── UserCenterModule
│ │ ├── UserCenterModule.h
│ │ └── UserCenterViewController.h
│ ├── HomePageModule
│ ├── HomePageModule
│ │ └── HomePageModule
│ │ │ ├── HomePageModule.h
│ │ │ ├── HomePageModule.m
│ │ │ ├── HomePageViewController.h
│ │ │ └── HomePageViewController.m
│ ├── LICENSE
│ └── README.md
│ ├── MGJRouter
│ ├── LICENSE
│ ├── MGJRouter
│ │ ├── MGJRouter.h
│ │ └── MGJRouter.m
│ └── README.md
│ ├── Manifest.lock
│ ├── Masonry
│ ├── LICENSE
│ ├── 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
│ └── README.md
│ ├── Pods.xcodeproj
│ └── project.pbxproj
│ ├── Target Support Files
│ ├── HomePageModule
│ │ ├── HomePageModule-dummy.m
│ │ ├── HomePageModule-prefix.pch
│ │ └── HomePageModule.xcconfig
│ ├── MGJRouter
│ │ ├── MGJRouter-dummy.m
│ │ ├── MGJRouter-prefix.pch
│ │ └── MGJRouter.xcconfig
│ ├── Masonry
│ │ ├── Masonry-dummy.m
│ │ ├── Masonry-prefix.pch
│ │ └── Masonry.xcconfig
│ ├── Pods-MainProject
│ │ ├── Pods-MainProject-acknowledgements.markdown
│ │ ├── Pods-MainProject-acknowledgements.plist
│ │ ├── Pods-MainProject-dummy.m
│ │ ├── Pods-MainProject-frameworks.sh
│ │ ├── Pods-MainProject-resources.sh
│ │ ├── Pods-MainProject.debug.xcconfig
│ │ └── Pods-MainProject.release.xcconfig
│ └── UserCenterModule
│ │ ├── UserCenterModule-dummy.m
│ │ ├── UserCenterModule-prefix.pch
│ │ └── UserCenterModule.xcconfig
│ └── UserCenterModule
│ ├── LICENSE
│ ├── README.md
│ └── UserCenterModule
│ └── UserCenterModule
│ ├── UserCenterModule.h
│ ├── UserCenterModule.m
│ ├── UserCenterViewController.h
│ └── UserCenterViewController.m
└── README.md
/MainProject/MainProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MainProject/MainProject.xcodeproj/project.xcworkspace/xcshareddata/MainProject.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 |
5 | },
6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7 | "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE" : 9223372036854775807,
8 | "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA" : 9223372036854775807,
9 | "CF91B64229F4C1818582FDA4FD550D05683AEC22" : 9223372036854775807
10 | },
11 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "52F60550-0929-4049-976E-CC7F4529FD5E",
12 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
13 | "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE" : "",
14 | "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA" : "%E4%B8%BB%E9%A1%B9%E7%9B%AE\/",
15 | "CF91B64229F4C1818582FDA4FD550D05683AEC22" : "LZUserModule\/"
16 | },
17 | "DVTSourceControlWorkspaceBlueprintNameKey" : "MainProject",
18 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
19 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "MainProject\/MainProject.xcodeproj",
20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
21 | {
22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/git.coding.net\/LiuXiaoZhuang\/LZSettingModule.git",
23 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
24 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE"
25 | },
26 | {
27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/DeveloperErenLiu\/ComponentArchitecture.git",
28 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
29 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA"
30 | },
31 | {
32 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/git.coding.net\/LiuXiaoZhuang\/LZUserModule.git",
33 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
34 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "CF91B64229F4C1818582FDA4FD550D05683AEC22"
35 | }
36 | ]
37 | }
--------------------------------------------------------------------------------
/MainProject/MainProject.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MainProject/MainProject.xcworkspace/xcshareddata/MainProject.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 |
5 | },
6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7 | "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE" : 9223372036854775807,
8 | "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA" : 9223372036854775807
9 | },
10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "2C00908F-ED6F-4D32-BC79-A762DEB9AA3F",
11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
12 | "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE" : "",
13 | "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA" : "%E4%B8%BB%E9%A1%B9%E7%9B%AE\/"
14 | },
15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "MainProject",
16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "MainProject\/MainProject.xcworkspace",
18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
19 | {
20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/git.coding.net\/LiuXiaoZhuang\/LZSettingModule.git",
21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "886A218BBABA36814F03B8E6F1DE5A7D962F2BBE"
23 | },
24 | {
25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/DeveloperErenLiu\/ComponentArchitecture.git",
26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8D3ECDD8AA8FCCD944BA169A438132632D88F2BA"
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/MainProject/MainProject/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2016/12/10.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/MainProject/MainProject/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2016/12/10.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // 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.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // 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.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // 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.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // 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.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/MainProject/MainProject/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/MainProject/MainProject/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MainProject/MainProject/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 |
29 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/MainProject/MainProject/HomeViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HomeViewController.h
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2018/10/23.
6 | // Copyright © 2018年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HomeViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MainProject/MainProject/HomeViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // HomeViewController.m
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2018/10/23.
6 | // Copyright © 2018年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "HomeViewController.h"
10 |
11 | @interface HomeViewController ()
12 |
13 | @end
14 |
15 | @implementation HomeViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view.
20 | }
21 |
22 | - (void)didReceiveMemoryWarning {
23 | [super didReceiveMemoryWarning];
24 | // Dispose of any resources that can be recreated.
25 | }
26 |
27 | /*
28 | #pragma mark - Navigation
29 |
30 | // In a storyboard-based application, you will often want to do a little preparation before navigation
31 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
32 | // Get the new view controller using [segue destinationViewController].
33 | // Pass the selected object to the new view controller.
34 | }
35 | */
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/MainProject/MainProject/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/MainProject/MainProject/LoginViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // LoginViewController.h
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2018/10/23.
6 | // Copyright © 2018年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LoginViewController : UIViewController
12 | @property (nonatomic, weak) id delegate;
13 | @end
14 |
--------------------------------------------------------------------------------
/MainProject/MainProject/LoginViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // LoginViewController.m
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2018/10/23.
6 | // Copyright © 2018年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "LoginViewController.h"
10 |
11 | @interface LoginViewController ()
12 |
13 | @end
14 |
15 | @implementation LoginViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view.
20 | }
21 |
22 | - (void)didReceiveMemoryWarning {
23 | [super didReceiveMemoryWarning];
24 | // Dispose of any resources that can be recreated.
25 | }
26 |
27 | /*
28 | #pragma mark - Navigation
29 |
30 | // In a storyboard-based application, you will often want to do a little preparation before navigation
31 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
32 | // Get the new view controller using [segue destinationViewController].
33 | // Pass the selected object to the new view controller.
34 | }
35 | */
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/MainProject/MainProject/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2016/12/10.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/MainProject/MainProject/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2016/12/10.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import
11 | #import "HomeViewController.h"
12 | #import "LoginViewController.h"
13 |
14 | const NSString *CTBUserCenterLoginDelegateKey = @"CTBUserCenterLoginDelegateKey";
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 |
21 | HomeViewController *homeVC = [[HomeViewController alloc] init];
22 | NSDictionary *params = @{CTBUserCenterLoginDelegateKey : homeVC};
23 | [MGJRouter openURL:@"CTB://UserCenter/UserLogin" withUserInfo:params completion:nil];
24 |
25 | [MGJRouter registerURLPattern:@"CTB://UserCenter/UserLogin" toHandler:^(NSDictionary *routerParameters) {
26 | UIViewController *homeVC = routerParameters[CTBUserCenterLoginDelegateKey];
27 | LoginViewController *loginVC = [[LoginViewController alloc] init];
28 | loginVC.delegate = homeVC;
29 | }];
30 | }
31 |
32 | - (IBAction)skipToUserCenterModuleAction:(UIButton *)sender {
33 |
34 | [MGJRouter openURL:@"CTB://UserCenter/PushMainVC"
35 | withUserInfo:@{@"navigationVC" : self.navigationController}
36 | completion:nil];
37 | }
38 |
39 | - (IBAction)skipToHomePageModuleAction:(UIButton *)sender {
40 |
41 | [MGJRouter openURL:@"CTB://HomePage/PushMainVC"
42 | withUserInfo:@{@"navigationVC" : self.navigationController}
43 | completion:nil];
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/MainProject/MainProject/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MainProject
4 | //
5 | // Created by 刘小壮 on 2016/12/10.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/MainProject/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '7.0'
2 |
3 | # CocoaPods官方地址
4 | source 'https://github.com/CocoaPods/Specs.git'
5 | # 私有仓库地址
6 | source 'https://git.coding.net/LiuXiaoZhuang/UserCenterModuleSpec.git'
7 | source 'https://git.coding.net/LiuXiaoZhuang/HomePageModuleSpec.git'
8 |
9 |
10 | target 'MainProject' do
11 | # 第三方库
12 | pod 'Masonry'
13 | pod 'MGJRouter'
14 |
15 | # 私有仓库
16 | pod 'UserCenterModule', '~> 1.2'
17 | pod 'HomePageModule', '~> 1.1'
18 | end
19 |
--------------------------------------------------------------------------------
/MainProject/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - HomePageModule (1.1):
3 | - MGJRouter
4 | - Masonry (1.0.2)
5 | - MGJRouter (0.9.3)
6 | - UserCenterModule (1.2):
7 | - MGJRouter
8 |
9 | DEPENDENCIES:
10 | - HomePageModule (~> 1.1)
11 | - Masonry
12 | - MGJRouter
13 | - UserCenterModule (~> 1.2)
14 |
15 | SPEC CHECKSUMS:
16 | HomePageModule: 203ab07925cc934a8c22b2fc6808a0eb673fbf69
17 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
18 | MGJRouter: f65821e2aeffc8f9e84b254c8f1c0dd80f048aa9
19 | UserCenterModule: 6e3f9d55c49316cb60f404b47558e347d993f588
20 |
21 | PODFILE CHECKSUM: 33575b4c2454a9e37de5cbfa3b65f1abf4a5025c
22 |
23 | COCOAPODS: 1.1.1
24 |
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/HomePageModule/HomePageModule.h:
--------------------------------------------------------------------------------
1 | ../../../HomePageModule/HomePageModule/HomePageModule/HomePageModule.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/HomePageModule/HomePageViewController.h:
--------------------------------------------------------------------------------
1 | ../../../HomePageModule/HomePageModule/HomePageModule/HomePageViewController.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/MGJRouter/MGJRouter.h:
--------------------------------------------------------------------------------
1 | ../../../MGJRouter/MGJRouter/MGJRouter.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASCompositeConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint+Private.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraintMaker.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASLayoutConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASUtilities.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASUtilities.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewAttribute.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/Masonry.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/UserCenterModule/UserCenterModule.h:
--------------------------------------------------------------------------------
1 | ../../../UserCenterModule/UserCenterModule/UserCenterModule/UserCenterModule.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Private/UserCenterModule/UserCenterViewController.h:
--------------------------------------------------------------------------------
1 | ../../../UserCenterModule/UserCenterModule/UserCenterModule/UserCenterViewController.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/HomePageModule/HomePageModule.h:
--------------------------------------------------------------------------------
1 | ../../../HomePageModule/HomePageModule/HomePageModule/HomePageModule.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/HomePageModule/HomePageViewController.h:
--------------------------------------------------------------------------------
1 | ../../../HomePageModule/HomePageModule/HomePageModule/HomePageViewController.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/MGJRouter/MGJRouter.h:
--------------------------------------------------------------------------------
1 | ../../../MGJRouter/MGJRouter/MGJRouter.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASCompositeConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint+Private.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraintMaker.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASLayoutConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASUtilities.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASUtilities.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewAttribute.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewConstraint.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/Masonry.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/UserCenterModule/UserCenterModule.h:
--------------------------------------------------------------------------------
1 | ../../../UserCenterModule/UserCenterModule/UserCenterModule/UserCenterModule.h
--------------------------------------------------------------------------------
/MainProject/Pods/Headers/Public/UserCenterModule/UserCenterViewController.h:
--------------------------------------------------------------------------------
1 | ../../../UserCenterModule/UserCenterModule/UserCenterModule/UserCenterViewController.h
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/HomePageModule/HomePageModule/HomePageModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // HomePageModule.h
3 | // HomePageModule
4 | //
5 | // Created by 刘小壮 on 2016/12/12.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HomePageModule : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/HomePageModule/HomePageModule/HomePageModule.m:
--------------------------------------------------------------------------------
1 | //
2 | // HomePageModule.m
3 | // HomePageModule
4 | //
5 | // Created by 刘小壮 on 2016/12/12.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "HomePageModule.h"
10 | #import
11 | #import "HomePageViewController.h"
12 |
13 | @implementation HomePageModule
14 |
15 | // 在load方法中自动注册,在主工程中不用写任何代码。
16 | + (void)load {
17 | [MGJRouter registerURLPattern:@"CTB://HomePage/PushMainVC" toHandler:^(NSDictionary *routerParameters) {
18 | UINavigationController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
19 |
20 | HomePageViewController *homePageVC = [[HomePageViewController alloc] init];
21 | [navigationVC pushViewController:homePageVC animated:YES];
22 | }];
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/HomePageModule/HomePageModule/HomePageViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // HomePageModule
4 | //
5 | // Created by 刘小壮 on 2016/12/11.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HomePageViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/HomePageModule/HomePageModule/HomePageViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // HomePageModule
4 | //
5 | // Created by 刘小壮 on 2016/12/11.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "HomePageViewController.h"
10 |
11 | @interface HomePageViewController ()
12 |
13 | @end
14 |
15 | @implementation HomePageViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | self.view.backgroundColor = [UIColor yellowColor];
21 | self.title = @"主页";
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 刘小壮
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/MainProject/Pods/HomePageModule/README.md:
--------------------------------------------------------------------------------
1 | #HomePageModule
2 |
--------------------------------------------------------------------------------
/MainProject/Pods/MGJRouter/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 mogujie
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/MainProject/Pods/MGJRouter/MGJRouter/MGJRouter.h:
--------------------------------------------------------------------------------
1 | //
2 | // MGJRouter.h
3 | // MGJFoundation
4 | //
5 | // Created by limboy on 12/9/14.
6 | // Copyright (c) 2014 juangua. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | extern NSString *const MGJRouterParameterURL;
12 | extern NSString *const MGJRouterParameterCompletion;
13 | extern NSString *const MGJRouterParameterUserInfo;
14 |
15 | /**
16 | * routerParameters 里内置的几个参数会用到上面定义的 string
17 | */
18 | typedef void (^MGJRouterHandler)(NSDictionary *routerParameters);
19 |
20 | /**
21 | * 需要返回一个 object,配合 objectForURL: 使用
22 | */
23 | typedef id (^MGJRouterObjectHandler)(NSDictionary *routerParameters);
24 |
25 | @interface MGJRouter : NSObject
26 |
27 | /**
28 | * 注册 URLPattern 对应的 Handler,在 handler 中可以初始化 VC,然后对 VC 做各种操作
29 | *
30 | * @param URLPattern 带上 scheme,如 mgj://beauty/:id
31 | * @param handler 该 block 会传一个字典,包含了注册的 URL 中对应的变量。
32 | * 假如注册的 URL 为 mgj://beauty/:id 那么,就会传一个 @{@"id": 4} 这样的字典过来
33 | */
34 | + (void)registerURLPattern:(NSString *)URLPattern toHandler:(MGJRouterHandler)handler;
35 |
36 | /**
37 | * 注册 URLPattern 对应的 ObjectHandler,需要返回一个 object 给调用方
38 | *
39 | * @param URLPattern 带上 scheme,如 mgj://beauty/:id
40 | * @param handler 该 block 会传一个字典,包含了注册的 URL 中对应的变量。
41 | * 假如注册的 URL 为 mgj://beauty/:id 那么,就会传一个 @{@"id": 4} 这样的字典过来
42 | * 自带的 key 为 @"url" 和 @"completion" (如果有的话)
43 | */
44 | + (void)registerURLPattern:(NSString *)URLPattern toObjectHandler:(MGJRouterObjectHandler)handler;
45 |
46 | /**
47 | * 取消注册某个 URL Pattern
48 | *
49 | * @param URLPattern
50 | */
51 | + (void)deregisterURLPattern:(NSString *)URLPattern;
52 |
53 | /**
54 | * 打开此 URL
55 | * 会在已注册的 URL -> Handler 中寻找,如果找到,则执行 Handler
56 | *
57 | * @param URL 带 Scheme,如 mgj://beauty/3
58 | */
59 | + (void)openURL:(NSString *)URL;
60 |
61 | /**
62 | * 打开此 URL,同时当操作完成时,执行额外的代码
63 | *
64 | * @param URL 带 Scheme 的 URL,如 mgj://beauty/4
65 | * @param completion URL 处理完成后的 callback,完成的判定跟具体的业务相关
66 | */
67 | + (void)openURL:(NSString *)URL completion:(void (^)(id result))completion;
68 |
69 | /**
70 | * 打开此 URL,带上附加信息,同时当操作完成时,执行额外的代码
71 | *
72 | * @param URL 带 Scheme 的 URL,如 mgj://beauty/4
73 | * @param parameters 附加参数
74 | * @param completion URL 处理完成后的 callback,完成的判定跟具体的业务相关
75 | */
76 | + (void)openURL:(NSString *)URL withUserInfo:(NSDictionary *)userInfo completion:(void (^)(id result))completion;
77 |
78 | /**
79 | * 查找谁对某个 URL 感兴趣,如果有的话,返回一个 object
80 | *
81 | * @param URL
82 | */
83 | + (id)objectForURL:(NSString *)URL;
84 |
85 | /**
86 | * 查找谁对某个 URL 感兴趣,如果有的话,返回一个 object
87 | *
88 | * @param URL
89 | * @param userInfo
90 | */
91 | + (id)objectForURL:(NSString *)URL withUserInfo:(NSDictionary *)userInfo;
92 |
93 | /**
94 | * 是否可以打开URL
95 | *
96 | * @param URL
97 | *
98 | * @return
99 | */
100 | + (BOOL)canOpenURL:(NSString *)URL;
101 |
102 | /**
103 | * 调用此方法来拼接 urlpattern 和 parameters
104 | *
105 | * #define MGJ_ROUTE_BEAUTY @"beauty/:id"
106 | * [MGJRouter generateURLWithPattern:MGJ_ROUTE_BEAUTY, @[@13]];
107 | *
108 | *
109 | * @param pattern url pattern 比如 @"beauty/:id"
110 | * @param parameters 一个数组,数量要跟 pattern 里的变量一致
111 | *
112 | * @return
113 | */
114 | + (NSString *)generateURLWithPattern:(NSString *)pattern parameters:(NSArray *)parameters;
115 | @end
116 |
--------------------------------------------------------------------------------
/MainProject/Pods/MGJRouter/MGJRouter/MGJRouter.m:
--------------------------------------------------------------------------------
1 | //
2 | // MGJRouter.m
3 | // MGJFoundation
4 | //
5 | // Created by limboy on 12/9/14.
6 | // Copyright (c) 2014 juangua. All rights reserved.
7 | //
8 |
9 | #import "MGJRouter.h"
10 | #import
11 |
12 | static NSString * const MGJ_ROUTER_WILDCARD_CHARACTER = @"~";
13 | static NSString *specialCharacters = @"/?&.";
14 |
15 | NSString *const MGJRouterParameterURL = @"MGJRouterParameterURL";
16 | NSString *const MGJRouterParameterCompletion = @"MGJRouterParameterCompletion";
17 | NSString *const MGJRouterParameterUserInfo = @"MGJRouterParameterUserInfo";
18 |
19 |
20 | @interface MGJRouter ()
21 | /**
22 | * 保存了所有已注册的 URL
23 | * 结构类似 @{@"beauty": @{@":id": {@"_", [block copy]}}}
24 | */
25 | @property (nonatomic) NSMutableDictionary *routes;
26 | @end
27 |
28 | @implementation MGJRouter
29 |
30 | + (instancetype)sharedInstance
31 | {
32 | static MGJRouter *instance = nil;
33 | static dispatch_once_t onceToken;
34 | dispatch_once(&onceToken, ^{
35 | instance = [[self alloc] init];
36 | });
37 | return instance;
38 | }
39 |
40 | + (void)registerURLPattern:(NSString *)URLPattern toHandler:(MGJRouterHandler)handler
41 | {
42 | [[self sharedInstance] addURLPattern:URLPattern andHandler:handler];
43 | }
44 |
45 | + (void)deregisterURLPattern:(NSString *)URLPattern
46 | {
47 | [[self sharedInstance] removeURLPattern:URLPattern];
48 | }
49 |
50 | + (void)openURL:(NSString *)URL
51 | {
52 | [self openURL:URL completion:nil];
53 | }
54 |
55 | + (void)openURL:(NSString *)URL completion:(void (^)(id result))completion
56 | {
57 | [self openURL:URL withUserInfo:nil completion:completion];
58 | }
59 |
60 | + (void)openURL:(NSString *)URL withUserInfo:(NSDictionary *)userInfo completion:(void (^)(id result))completion
61 | {
62 | URL = [URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
63 | NSMutableDictionary *parameters = [[self sharedInstance] extractParametersFromURL:URL];
64 |
65 | [parameters enumerateKeysAndObjectsUsingBlock:^(id key, NSString *obj, BOOL *stop) {
66 | if ([obj isKindOfClass:[NSString class]]) {
67 | parameters[key] = [obj stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
68 | }
69 | }];
70 |
71 | if (parameters) {
72 | MGJRouterHandler handler = parameters[@"block"];
73 | if (completion) {
74 | parameters[MGJRouterParameterCompletion] = completion;
75 | }
76 | if (userInfo) {
77 | parameters[MGJRouterParameterUserInfo] = userInfo;
78 | }
79 | if (handler) {
80 | [parameters removeObjectForKey:@"block"];
81 | handler(parameters);
82 | }
83 | }
84 | }
85 |
86 | + (BOOL)canOpenURL:(NSString *)URL
87 | {
88 | return [[self sharedInstance] extractParametersFromURL:URL] ? YES : NO;
89 | }
90 |
91 | + (NSString *)generateURLWithPattern:(NSString *)pattern parameters:(NSArray *)parameters
92 | {
93 | NSInteger startIndexOfColon = 0;
94 |
95 | NSMutableArray *placeholders = [NSMutableArray array];
96 |
97 | for (int i = 0; i < pattern.length; i++) {
98 | NSString *character = [NSString stringWithFormat:@"%c", [pattern characterAtIndex:i]];
99 | if ([character isEqualToString:@":"]) {
100 | startIndexOfColon = i;
101 | }
102 | if ([specialCharacters rangeOfString:character].location != NSNotFound && i > (startIndexOfColon + 1) && startIndexOfColon) {
103 | NSRange range = NSMakeRange(startIndexOfColon, i - startIndexOfColon);
104 | NSString *placeholder = [pattern substringWithRange:range];
105 | if (![self checkIfContainsSpecialCharacter:placeholder]) {
106 | [placeholders addObject:placeholder];
107 | startIndexOfColon = 0;
108 | }
109 | }
110 | if (i == pattern.length - 1 && startIndexOfColon) {
111 | NSRange range = NSMakeRange(startIndexOfColon, i - startIndexOfColon + 1);
112 | NSString *placeholder = [pattern substringWithRange:range];
113 | if (![self checkIfContainsSpecialCharacter:placeholder]) {
114 | [placeholders addObject:placeholder];
115 | }
116 | }
117 | }
118 |
119 | __block NSString *parsedResult = pattern;
120 |
121 | [placeholders enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
122 | idx = parameters.count > idx ? idx : parameters.count - 1;
123 | parsedResult = [parsedResult stringByReplacingOccurrencesOfString:obj withString:parameters[idx]];
124 | }];
125 |
126 | return parsedResult;
127 | }
128 |
129 | + (id)objectForURL:(NSString *)URL withUserInfo:(NSDictionary *)userInfo
130 | {
131 | MGJRouter *router = [MGJRouter sharedInstance];
132 |
133 | URL = [URL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
134 | NSMutableDictionary *parameters = [router extractParametersFromURL:URL];
135 | MGJRouterObjectHandler handler = parameters[@"block"];
136 |
137 | if (handler) {
138 | if (userInfo) {
139 | parameters[MGJRouterParameterUserInfo] = userInfo;
140 | }
141 | [parameters removeObjectForKey:@"block"];
142 | return handler(parameters);
143 | }
144 | return nil;
145 | }
146 |
147 | + (id)objectForURL:(NSString *)URL
148 | {
149 | return [self objectForURL:URL withUserInfo:nil];
150 | }
151 |
152 | + (void)registerURLPattern:(NSString *)URLPattern toObjectHandler:(MGJRouterObjectHandler)handler
153 | {
154 | [[self sharedInstance] addURLPattern:URLPattern andObjectHandler:handler];
155 | }
156 |
157 | - (void)addURLPattern:(NSString *)URLPattern andHandler:(MGJRouterHandler)handler
158 | {
159 | NSMutableDictionary *subRoutes = [self addURLPattern:URLPattern];
160 | if (handler && subRoutes) {
161 | subRoutes[@"_"] = [handler copy];
162 | }
163 | }
164 |
165 | - (void)addURLPattern:(NSString *)URLPattern andObjectHandler:(MGJRouterObjectHandler)handler
166 | {
167 | NSMutableDictionary *subRoutes = [self addURLPattern:URLPattern];
168 | if (handler && subRoutes) {
169 | subRoutes[@"_"] = [handler copy];
170 | }
171 | }
172 |
173 | - (NSMutableDictionary *)addURLPattern:(NSString *)URLPattern
174 | {
175 | NSArray *pathComponents = [self pathComponentsFromURL:URLPattern];
176 |
177 | NSInteger index = 0;
178 | NSMutableDictionary* subRoutes = self.routes;
179 |
180 | while (index < pathComponents.count) {
181 | NSString* pathComponent = pathComponents[index];
182 | if (![subRoutes objectForKey:pathComponent]) {
183 | subRoutes[pathComponent] = [[NSMutableDictionary alloc] init];
184 | }
185 | subRoutes = subRoutes[pathComponent];
186 | index++;
187 | }
188 | return subRoutes;
189 | }
190 |
191 | #pragma mark - Utils
192 |
193 | - (NSMutableDictionary *)extractParametersFromURL:(NSString *)url
194 | {
195 | NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
196 |
197 | parameters[MGJRouterParameterURL] = url;
198 |
199 | NSMutableDictionary* subRoutes = self.routes;
200 | NSArray* pathComponents = [self pathComponentsFromURL:url];
201 |
202 | BOOL found = NO;
203 | // borrowed from HHRouter(https://github.com/Huohua/HHRouter)
204 | for (NSString* pathComponent in pathComponents) {
205 |
206 | // 对 key 进行排序,这样可以把 ~ 放到最后
207 | NSArray *subRoutesKeys =[subRoutes.allKeys sortedArrayUsingComparator:^NSComparisonResult(NSString *obj1, NSString *obj2) {
208 | return [obj1 compare:obj2];
209 | }];
210 |
211 | for (NSString* key in subRoutesKeys) {
212 | if ([key isEqualToString:pathComponent] || [key isEqualToString:MGJ_ROUTER_WILDCARD_CHARACTER]) {
213 | found = YES;
214 | subRoutes = subRoutes[key];
215 | break;
216 | } else if ([key hasPrefix:@":"]) {
217 | found = YES;
218 | subRoutes = subRoutes[key];
219 | NSString *newKey = [key substringFromIndex:1];
220 | NSString *newPathComponent = pathComponent;
221 | // 再做一下特殊处理,比如 :id.html -> :id
222 | if ([self.class checkIfContainsSpecialCharacter:key]) {
223 | NSCharacterSet *specialCharacterSet = [NSCharacterSet characterSetWithCharactersInString:specialCharacters];
224 | NSRange range = [key rangeOfCharacterFromSet:specialCharacterSet];
225 | if (range.location != NSNotFound) {
226 | // 把 pathComponent 后面的部分也去掉
227 | newKey = [newKey substringToIndex:range.location - 1];
228 | NSString *suffixToStrip = [key substringFromIndex:range.location];
229 | newPathComponent = [newPathComponent stringByReplacingOccurrencesOfString:suffixToStrip withString:@""];
230 | }
231 | }
232 | parameters[newKey] = newPathComponent;
233 | break;
234 | }
235 | }
236 |
237 | // 如果没有找到该 pathComponent 对应的 handler,则以上一层的 handler 作为 fallback
238 | if (!found && !subRoutes[@"_"]) {
239 | return nil;
240 | }
241 | }
242 |
243 | // Extract Params From Query.
244 | NSArray* pathInfo = [url componentsSeparatedByString:@"?"];
245 | if (pathInfo.count > 1) {
246 | NSString* parametersString = [pathInfo objectAtIndex:1];
247 | NSArray* paramStringArr = [parametersString componentsSeparatedByString:@"&"];
248 | for (NSString* paramString in paramStringArr) {
249 | NSArray* paramArr = [paramString componentsSeparatedByString:@"="];
250 | if (paramArr.count > 1) {
251 | NSString* key = [paramArr objectAtIndex:0];
252 | NSString* value = [paramArr objectAtIndex:1];
253 | parameters[key] = value;
254 | }
255 | }
256 | }
257 |
258 | if (subRoutes[@"_"]) {
259 | parameters[@"block"] = [subRoutes[@"_"] copy];
260 | }
261 |
262 | return parameters;
263 | }
264 |
265 | - (void)removeURLPattern:(NSString *)URLPattern
266 | {
267 | NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:[self pathComponentsFromURL:URLPattern]];
268 |
269 | // 只删除该 pattern 的最后一级
270 | if (pathComponents.count >= 1) {
271 | // 假如 URLPattern 为 a/b/c, components 就是 @"a.b.c" 正好可以作为 KVC 的 key
272 | NSString *components = [pathComponents componentsJoinedByString:@"."];
273 | NSMutableDictionary *route = [self.routes valueForKeyPath:components];
274 |
275 | if (route.count >= 1) {
276 | NSString *lastComponent = [pathComponents lastObject];
277 | [pathComponents removeLastObject];
278 |
279 | // 有可能是根 key,这样就是 self.routes 了
280 | route = self.routes;
281 | if (pathComponents.count) {
282 | NSString *componentsWithoutLast = [pathComponents componentsJoinedByString:@"."];
283 | route = [self.routes valueForKeyPath:componentsWithoutLast];
284 | }
285 | [route removeObjectForKey:lastComponent];
286 | }
287 | }
288 | }
289 |
290 | - (NSArray*)pathComponentsFromURL:(NSString*)URL
291 | {
292 | NSMutableArray *pathComponents = [NSMutableArray array];
293 | if ([URL rangeOfString:@"://"].location != NSNotFound) {
294 | NSArray *pathSegments = [URL componentsSeparatedByString:@"://"];
295 | // 如果 URL 包含协议,那么把协议作为第一个元素放进去
296 | [pathComponents addObject:pathSegments[0]];
297 |
298 | // 如果只有协议,那么放一个占位符
299 | if ((pathSegments.count == 2 && ((NSString *)pathSegments[1]).length) || pathSegments.count < 2) {
300 | [pathComponents addObject:MGJ_ROUTER_WILDCARD_CHARACTER];
301 | }
302 |
303 | URL = [URL substringFromIndex:[URL rangeOfString:@"://"].location + 3];
304 | }
305 |
306 | for (NSString *pathComponent in [[NSURL URLWithString:URL] pathComponents]) {
307 | if ([pathComponent isEqualToString:@"/"]) continue;
308 | if ([[pathComponent substringToIndex:1] isEqualToString:@"?"]) break;
309 | [pathComponents addObject:pathComponent];
310 | }
311 | return [pathComponents copy];
312 | }
313 |
314 | - (NSMutableDictionary *)routes
315 | {
316 | if (!_routes) {
317 | _routes = [[NSMutableDictionary alloc] init];
318 | }
319 | return _routes;
320 | }
321 |
322 | #pragma mark - Utils
323 |
324 | + (BOOL)checkIfContainsSpecialCharacter:(NSString *)checkedString {
325 | NSCharacterSet *specialCharactersSet = [NSCharacterSet characterSetWithCharactersInString:specialCharacters];
326 | return [checkedString rangeOfCharacterFromSet:specialCharactersSet].location != NSNotFound;
327 | }
328 |
329 | @end
330 |
--------------------------------------------------------------------------------
/MainProject/Pods/MGJRouter/README.md:
--------------------------------------------------------------------------------
1 | # MGJRouter
2 | 一个高效/灵活的 iOS URL Router
3 |
4 | ### 2015-08-22 更新
5 |
6 | #### 添加了同步获取 Object 的方法
7 |
8 | 有些场景我们可能需要根据 URL 获取某个 Object,所以就添加了这个方法
9 |
10 | ```objc
11 | UIView *searchTopBar = [MGJRouter objectForURL:@"search_top_bar"];
12 | ```
13 |
14 | ## 为什么要再造一个轮子?
15 | 已经有几款不错的 Router 了,如 [JLRoutes](https://github.com/joeldev/JLRoutes), [HHRouter](https://github.com/Huohua/HHRouter), 但细看了下之后发现,还是不太满足需求。
16 |
17 | JLRoutes 的问题主要在于查找 URL 的实现不够高效,通过遍历而不是匹配。还有就是功能偏多。
18 |
19 | HHRouter 的 URL 查找是基于匹配,所以会更高效,MGJRouter 也是采用的这种方法,但它跟 ViewController 绑定地过于紧密,一定程度上降低了灵活性。
20 |
21 | 于是就有了 MGJRouter。
22 |
23 | ## 安装
24 |
25 | ```
26 | pod 'MGJRouter', '~>0.9.0'
27 | ```
28 |
29 | ## 使用姿势
30 |
31 | ### 最基本的使用
32 |
33 | ```objc
34 | [MGJRouter registerURLPattern:@"mgj://foo/bar" toHandler:^(NSDictionary *routerParameters) {
35 | NSLog(@"routerParameterUserInfo:%@", routerParameters[MGJRouterParameterUserInfo]);
36 | }];
37 |
38 | [MGJRouter openURL:@"mgj://foo/bar"];
39 | ```
40 |
41 | 当匹配到 URL 后,`routerParameters` 会自带几个 key
42 |
43 | ```objc
44 | extern NSString *const MGJRouterParameterURL;
45 | extern NSString *const MGJRouterParameterCompletion;
46 | extern NSString *const MGJRouterParameterUserInfo;
47 | ```
48 |
49 | ### 处理中文也没有问题
50 |
51 | ```objc
52 | [MGJRouter registerURLPattern:@"mgj://category/家居" toHandler:^(NSDictionary *routerParameters) {
53 | NSLog(@"routerParameters:%@", routerParameters);
54 | }];
55 |
56 | [MGJRouter openURL:@"mgj://category/家居"];
57 | ```
58 |
59 | ### Open 时,可以传一些 userinfo 过去
60 |
61 | ```objc
62 | [MGJRouter registerURLPattern:@"mgj://category/travel" toHandler:^(NSDictionary *routerParameters) {
63 | NSLog(@"routerParameters[MGJRouterParameterUserInfo]:%@", routerParameters[MGJRouterParameterUserInfo]);
64 | // @{@"user_id": @1900}
65 | }];
66 |
67 | [MGJRouter openURL:@"mgj://category/travel" withUserInfo:@{@"user_id": @1900} completion:nil];
68 | ```
69 |
70 | ### 如果有可变参数(包括 URL Query Parameter)会被自动解析
71 |
72 | ```objc
73 | [MGJRouter registerURLPattern:@"mgj://search/:query" toHandler:^(NSDictionary *routerParameters) {
74 | NSLog(@"routerParameters[query]:%@", routerParameters[@"query"]); // bicycle
75 | NSLog(@"routerParameters[color]:%@", routerParameters[@"color"]); // red
76 | }];
77 |
78 | [MGJRouter openURL:@"mgj://search/bicycle?color=red"];
79 | ```
80 |
81 | ### 定义一个全局的 URL Pattern 作为 Fallback
82 |
83 | ```objc
84 | [MGJRouter registerURLPattern:@"mgj://" toHandler:^(NSDictionary *routerParameters) {
85 | NSLog(@"没有人处理该 URL,就只能 fallback 到这里了");
86 | }];
87 |
88 | [MGJRouter openURL:@"mgj://search/travel/china?has_travelled=0"];
89 | ```
90 |
91 | ### 当 Open 结束时,执行 Completion Block
92 |
93 | ```objc
94 | [MGJRouter registerURLPattern:@"mgj://detail" toHandler:^(NSDictionary *routerParameters) {
95 | NSLog(@"匹配到了 url, 一会会执行 Completion Block");
96 |
97 | // 模拟 push 一个 VC
98 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
99 | void (^completion)() = routerParameters[MGJRouterParameterCompletion];
100 | if (completion) {
101 | completion();
102 | }
103 | });
104 | }];
105 |
106 | [MGJRouter openURL:@"mgj://detail" withUserInfo:nil completion:^{
107 | [self appendLog:@"Open 结束,我是 Completion Block"];
108 | }];
109 | ```
110 |
111 | ### 生成 URL
112 |
113 | URL 的处理一不小心,就容易散落在项目的各个角落,不容易管理。比如注册时的 pattern 是 `mgj://beauty/:id`,然后 open 时就是 `mgj://beauty/123`,这样到时候 url 有改动,处理起来就会很麻烦,不好统一管理。
114 |
115 | 所以 MGJRouter 提供了一个类方法来处理这个问题。
116 |
117 | ```objc
118 | + (NSString *)generateURLWithPattern:(NSString *)pattern parameters:(NSArray *)parameters;
119 | ```
120 |
121 | 使用方式
122 |
123 | ```objc
124 | #define TEMPLATE_URL @"mgj://search/:keyword"
125 |
126 | [MGJRouter registerURLPattern:TEMPLATE_URL toHandler:^(NSDictionary *routerParameters) {
127 | NSLog(@"routerParameters[keyword]:%@", routerParameters[@"keyword"]); // Hangzhou
128 | }];
129 |
130 | [MGJRouter openURL:[MGJRouter generateURLWithPattern:TEMPLATE_URL parameters:@[@"Hangzhou"]]];
131 | }
132 | ```
133 |
134 | 这样就可以在一个地方定义所有的 URL Pattern,使用时,用这个方法生成 URL 就行了。
135 |
136 |
137 | ## 协议
138 |
139 | MGJRouter 被许可在 MIT 协议下使用。查阅 LICENSE 文件来获得更多信息。
140 |
--------------------------------------------------------------------------------
/MainProject/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - HomePageModule (1.1):
3 | - MGJRouter
4 | - Masonry (1.0.2)
5 | - MGJRouter (0.9.3)
6 | - UserCenterModule (1.2):
7 | - MGJRouter
8 |
9 | DEPENDENCIES:
10 | - HomePageModule (~> 1.1)
11 | - Masonry
12 | - MGJRouter
13 | - UserCenterModule (~> 1.2)
14 |
15 | SPEC CHECKSUMS:
16 | HomePageModule: 203ab07925cc934a8c22b2fc6808a0eb673fbf69
17 | Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
18 | MGJRouter: f65821e2aeffc8f9e84b254c8f1c0dd80f048aa9
19 | UserCenterModule: 6e3f9d55c49316cb60f404b47558e347d993f588
20 |
21 | PODFILE CHECKSUM: 33575b4c2454a9e37de5cbfa3b65f1abf4a5025c
22 |
23 | COCOAPODS: 1.1.1
24 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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)setOffset:(CGFloat)offset {
133 | for (MASConstraint *constraint in self.childConstraints) {
134 | constraint.offset = offset;
135 | }
136 | }
137 |
138 | - (void)setSizeOffset:(CGSize)sizeOffset {
139 | for (MASConstraint *constraint in self.childConstraints) {
140 | constraint.sizeOffset = sizeOffset;
141 | }
142 | }
143 |
144 | - (void)setCenterOffset:(CGPoint)centerOffset {
145 | for (MASConstraint *constraint in self.childConstraints) {
146 | constraint.centerOffset = centerOffset;
147 | }
148 | }
149 |
150 | #pragma mark - MASConstraint
151 |
152 | - (void)activate {
153 | for (MASConstraint *constraint in self.childConstraints) {
154 | [constraint activate];
155 | }
156 | }
157 |
158 | - (void)deactivate {
159 | for (MASConstraint *constraint in self.childConstraints) {
160 | [constraint deactivate];
161 | }
162 | }
163 |
164 | - (void)install {
165 | for (MASConstraint *constraint in self.childConstraints) {
166 | constraint.updateExisting = self.updateExisting;
167 | [constraint install];
168 | }
169 | }
170 |
171 | - (void)uninstall {
172 | for (MASConstraint *constraint in self.childConstraints) {
173 | [constraint uninstall];
174 | }
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * Enables Constraints to be created with chainable syntax
13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint)
14 | * or a group of NSLayoutConstraints (MASComposisteConstraint)
15 | */
16 | @interface MASConstraint : NSObject
17 |
18 | // Chaining Support
19 |
20 | /**
21 | * Modifies the NSLayoutConstraint constant,
22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
24 | */
25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets;
26 |
27 | /**
28 | * Modifies the NSLayoutConstraint constant,
29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
31 | */
32 | - (MASConstraint * (^)(CGSize offset))sizeOffset;
33 |
34 | /**
35 | * Modifies the NSLayoutConstraint constant,
36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
38 | */
39 | - (MASConstraint * (^)(CGPoint offset))centerOffset;
40 |
41 | /**
42 | * Modifies the NSLayoutConstraint constant
43 | */
44 | - (MASConstraint * (^)(CGFloat offset))offset;
45 |
46 | /**
47 | * Modifies the NSLayoutConstraint constant based on a value type
48 | */
49 | - (MASConstraint * (^)(NSValue *value))valueOffset;
50 |
51 | /**
52 | * Sets the NSLayoutConstraint multiplier property
53 | */
54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
55 |
56 | /**
57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy
58 | */
59 | - (MASConstraint * (^)(CGFloat divider))dividedBy;
60 |
61 | /**
62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority
63 | */
64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority;
65 |
66 | /**
67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow
68 | */
69 | - (MASConstraint * (^)())priorityLow;
70 |
71 | /**
72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium
73 | */
74 | - (MASConstraint * (^)())priorityMedium;
75 |
76 | /**
77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh
78 | */
79 | - (MASConstraint * (^)())priorityHigh;
80 |
81 | /**
82 | * Sets the constraint relation to NSLayoutRelationEqual
83 | * returns a block which accepts one of the following:
84 | * MASViewAttribute, UIView, NSValue, NSArray
85 | * see readme for more details.
86 | */
87 | - (MASConstraint * (^)(id attr))equalTo;
88 |
89 | /**
90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual
91 | * returns a block which accepts one of the following:
92 | * MASViewAttribute, UIView, NSValue, NSArray
93 | * see readme for more details.
94 | */
95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo;
96 |
97 | /**
98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual
99 | * returns a block which accepts one of the following:
100 | * MASViewAttribute, UIView, NSValue, NSArray
101 | * see readme for more details.
102 | */
103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo;
104 |
105 | /**
106 | * Optional semantic property which has no effect but improves the readability of constraint
107 | */
108 | - (MASConstraint *)with;
109 |
110 | /**
111 | * Optional semantic property which has no effect but improves the readability of constraint
112 | */
113 | - (MASConstraint *)and;
114 |
115 | /**
116 | * Creates a new MASCompositeConstraint with the called attribute and reciever
117 | */
118 | - (MASConstraint *)left;
119 | - (MASConstraint *)top;
120 | - (MASConstraint *)right;
121 | - (MASConstraint *)bottom;
122 | - (MASConstraint *)leading;
123 | - (MASConstraint *)trailing;
124 | - (MASConstraint *)width;
125 | - (MASConstraint *)height;
126 | - (MASConstraint *)centerX;
127 | - (MASConstraint *)centerY;
128 | - (MASConstraint *)baseline;
129 |
130 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
131 |
132 | - (MASConstraint *)firstBaseline;
133 | - (MASConstraint *)lastBaseline;
134 |
135 | #endif
136 |
137 | #if TARGET_OS_IPHONE || TARGET_OS_TV
138 |
139 | - (MASConstraint *)leftMargin;
140 | - (MASConstraint *)rightMargin;
141 | - (MASConstraint *)topMargin;
142 | - (MASConstraint *)bottomMargin;
143 | - (MASConstraint *)leadingMargin;
144 | - (MASConstraint *)trailingMargin;
145 | - (MASConstraint *)centerXWithinMargins;
146 | - (MASConstraint *)centerYWithinMargins;
147 |
148 | #endif
149 |
150 |
151 | /**
152 | * Sets the constraint debug name
153 | */
154 | - (MASConstraint * (^)(id key))key;
155 |
156 | // NSLayoutConstraint constant Setters
157 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks
158 |
159 | /**
160 | * Modifies the NSLayoutConstraint constant,
161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
162 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
163 | */
164 | - (void)setInsets:(MASEdgeInsets)insets;
165 |
166 | /**
167 | * Modifies the NSLayoutConstraint constant,
168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
169 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
170 | */
171 | - (void)setSizeOffset:(CGSize)sizeOffset;
172 |
173 | /**
174 | * Modifies the NSLayoutConstraint constant,
175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
176 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
177 | */
178 | - (void)setCenterOffset:(CGPoint)centerOffset;
179 |
180 | /**
181 | * Modifies the NSLayoutConstraint constant
182 | */
183 | - (void)setOffset:(CGFloat)offset;
184 |
185 |
186 | // NSLayoutConstraint Installation support
187 |
188 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
189 | /**
190 | * Whether or not to go through the animator proxy when modifying the constraint
191 | */
192 | @property (nonatomic, copy, readonly) MASConstraint *animator;
193 | #endif
194 |
195 | /**
196 | * Activates an NSLayoutConstraint if it's supported by an OS.
197 | * Invokes install otherwise.
198 | */
199 | - (void)activate;
200 |
201 | /**
202 | * Deactivates previously installed/activated NSLayoutConstraint.
203 | */
204 | - (void)deactivate;
205 |
206 | /**
207 | * Creates a NSLayoutConstraint and adds it to the appropriate view.
208 | */
209 | - (void)install;
210 |
211 | /**
212 | * Removes previously installed NSLayoutConstraint
213 | */
214 | - (void)uninstall;
215 |
216 | @end
217 |
218 |
219 | /**
220 | * Convenience auto-boxing macros for MASConstraint methods.
221 | *
222 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
223 | * A potential drawback of this is that the unprefixed macros will appear in global scope.
224 | */
225 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__)))
226 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
227 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
228 |
229 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__)))
230 |
231 |
232 | #ifdef MAS_SHORTHAND_GLOBALS
233 |
234 | #define equalTo(...) mas_equalTo(__VA_ARGS__)
235 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__)
236 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__)
237 |
238 | #define offset(...) mas_offset(__VA_ARGS__)
239 |
240 | #endif
241 |
242 |
243 | @interface MASConstraint (AutoboxingSupport)
244 |
245 | /**
246 | * Aliases to corresponding relation methods (for shorthand macros)
247 | * Also needed to aid autocompletion
248 | */
249 | - (MASConstraint * (^)(id attr))mas_equalTo;
250 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo;
251 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo;
252 |
253 | /**
254 | * A dummy method to aid autocompletion
255 | */
256 | - (MASConstraint * (^)(id offset))mas_offset;
257 |
258 | @end
259 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.m
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 1/20/14.
6 | //
7 |
8 | #import "MASConstraint.h"
9 | #import "MASConstraint+Private.h"
10 |
11 | #define MASMethodNotImplemented() \
12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \
13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \
14 | userInfo:nil]
15 |
16 | @implementation MASConstraint
17 |
18 | #pragma mark - Init
19 |
20 | - (id)init {
21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly.");
22 | return [super init];
23 | }
24 |
25 | #pragma mark - NSLayoutRelation proxies
26 |
27 | - (MASConstraint * (^)(id))equalTo {
28 | return ^id(id attribute) {
29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
30 | };
31 | }
32 |
33 | - (MASConstraint * (^)(id))mas_equalTo {
34 | return ^id(id attribute) {
35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
36 | };
37 | }
38 |
39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo {
40 | return ^id(id attribute) {
41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
42 | };
43 | }
44 |
45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo {
46 | return ^id(id attribute) {
47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
48 | };
49 | }
50 |
51 | - (MASConstraint * (^)(id))lessThanOrEqualTo {
52 | return ^id(id attribute) {
53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
54 | };
55 | }
56 |
57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo {
58 | return ^id(id attribute) {
59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
60 | };
61 | }
62 |
63 | #pragma mark - MASLayoutPriority proxies
64 |
65 | - (MASConstraint * (^)())priorityLow {
66 | return ^id{
67 | self.priority(MASLayoutPriorityDefaultLow);
68 | return self;
69 | };
70 | }
71 |
72 | - (MASConstraint * (^)())priorityMedium {
73 | return ^id{
74 | self.priority(MASLayoutPriorityDefaultMedium);
75 | return self;
76 | };
77 | }
78 |
79 | - (MASConstraint * (^)())priorityHigh {
80 | return ^id{
81 | self.priority(MASLayoutPriorityDefaultHigh);
82 | return self;
83 | };
84 | }
85 |
86 | #pragma mark - NSLayoutConstraint constant proxies
87 |
88 | - (MASConstraint * (^)(MASEdgeInsets))insets {
89 | return ^id(MASEdgeInsets insets){
90 | self.insets = insets;
91 | return self;
92 | };
93 | }
94 |
95 | - (MASConstraint * (^)(CGSize))sizeOffset {
96 | return ^id(CGSize offset) {
97 | self.sizeOffset = offset;
98 | return self;
99 | };
100 | }
101 |
102 | - (MASConstraint * (^)(CGPoint))centerOffset {
103 | return ^id(CGPoint offset) {
104 | self.centerOffset = offset;
105 | return self;
106 | };
107 | }
108 |
109 | - (MASConstraint * (^)(CGFloat))offset {
110 | return ^id(CGFloat offset){
111 | self.offset = offset;
112 | return self;
113 | };
114 | }
115 |
116 | - (MASConstraint * (^)(NSValue *value))valueOffset {
117 | return ^id(NSValue *offset) {
118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
119 | [self setLayoutConstantWithValue:offset];
120 | return self;
121 | };
122 | }
123 |
124 | - (MASConstraint * (^)(id offset))mas_offset {
125 | // Will never be called due to macro
126 | return nil;
127 | }
128 |
129 | #pragma mark - NSLayoutConstraint constant setter
130 |
131 | - (void)setLayoutConstantWithValue:(NSValue *)value {
132 | if ([value isKindOfClass:NSNumber.class]) {
133 | self.offset = [(NSNumber *)value doubleValue];
134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) {
135 | CGPoint point;
136 | [value getValue:&point];
137 | self.centerOffset = point;
138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) {
139 | CGSize size;
140 | [value getValue:&size];
141 | self.sizeOffset = size;
142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) {
143 | MASEdgeInsets insets;
144 | [value getValue:&insets];
145 | self.insets = insets;
146 | } else {
147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value);
148 | }
149 | }
150 |
151 | #pragma mark - Semantic properties
152 |
153 | - (MASConstraint *)with {
154 | return self;
155 | }
156 |
157 | - (MASConstraint *)and {
158 | return self;
159 | }
160 |
161 | #pragma mark - Chaining
162 |
163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute {
164 | MASMethodNotImplemented();
165 | }
166 |
167 | - (MASConstraint *)left {
168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
169 | }
170 |
171 | - (MASConstraint *)top {
172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
173 | }
174 |
175 | - (MASConstraint *)right {
176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
177 | }
178 |
179 | - (MASConstraint *)bottom {
180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
181 | }
182 |
183 | - (MASConstraint *)leading {
184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
185 | }
186 |
187 | - (MASConstraint *)trailing {
188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
189 | }
190 |
191 | - (MASConstraint *)width {
192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
193 | }
194 |
195 | - (MASConstraint *)height {
196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
197 | }
198 |
199 | - (MASConstraint *)centerX {
200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
201 | }
202 |
203 | - (MASConstraint *)centerY {
204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
205 | }
206 |
207 | - (MASConstraint *)baseline {
208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
209 | }
210 |
211 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
212 |
213 | - (MASConstraint *)firstBaseline {
214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
215 | }
216 | - (MASConstraint *)lastBaseline {
217 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
218 | }
219 |
220 | #endif
221 |
222 | #if TARGET_OS_IPHONE || TARGET_OS_TV
223 |
224 | - (MASConstraint *)leftMargin {
225 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
226 | }
227 |
228 | - (MASConstraint *)rightMargin {
229 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
230 | }
231 |
232 | - (MASConstraint *)topMargin {
233 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
234 | }
235 |
236 | - (MASConstraint *)bottomMargin {
237 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
238 | }
239 |
240 | - (MASConstraint *)leadingMargin {
241 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
242 | }
243 |
244 | - (MASConstraint *)trailingMargin {
245 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
246 | }
247 |
248 | - (MASConstraint *)centerXWithinMargins {
249 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
250 | }
251 |
252 | - (MASConstraint *)centerYWithinMargins {
253 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
254 | }
255 |
256 | #endif
257 |
258 | #pragma mark - Abstract
259 |
260 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); }
261 |
262 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); }
263 |
264 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); }
265 |
266 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); }
267 |
268 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); }
269 |
270 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); }
271 |
272 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); }
273 |
274 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); }
275 |
276 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); }
277 |
278 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
279 |
280 | - (MASConstraint *)animator { MASMethodNotImplemented(); }
281 |
282 | #endif
283 |
284 | - (void)activate { MASMethodNotImplemented(); }
285 |
286 | - (void)deactivate { MASMethodNotImplemented(); }
287 |
288 | - (void)install { MASMethodNotImplemented(); }
289 |
290 | - (void)uninstall { MASMethodNotImplemented(); }
291 |
292 | @end
293 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | typedef NS_OPTIONS(NSInteger, MASAttribute) {
13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft,
14 | MASAttributeRight = 1 << NSLayoutAttributeRight,
15 | MASAttributeTop = 1 << NSLayoutAttributeTop,
16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom,
17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading,
18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth,
20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight,
21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24 |
25 | #if (__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 TARGET_OS_IPHONE || TARGET_OS_TV
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 TARGET_OS_IPHONE || TARGET_OS_TV
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 MASConstrait 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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASConstraintMaker.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraintMaker.h"
10 | #import "MASViewConstraint.h"
11 | #import "MASCompositeConstraint.h"
12 | #import "MASConstraint+Private.h"
13 | #import "MASViewAttribute.h"
14 | #import "View+MASAdditions.h"
15 |
16 | @interface MASConstraintMaker ()
17 |
18 | @property (nonatomic, weak) MAS_VIEW *view;
19 | @property (nonatomic, strong) NSMutableArray *constraints;
20 |
21 | @end
22 |
23 | @implementation MASConstraintMaker
24 |
25 | - (id)initWithView:(MAS_VIEW *)view {
26 | self = [super init];
27 | if (!self) return nil;
28 |
29 | self.view = view;
30 | self.constraints = NSMutableArray.new;
31 |
32 | return self;
33 | }
34 |
35 | - (NSArray *)install {
36 | if (self.removeExisting) {
37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view];
38 | for (MASConstraint *constraint in installedConstraints) {
39 | [constraint uninstall];
40 | }
41 | }
42 | NSArray *constraints = self.constraints.copy;
43 | for (MASConstraint *constraint in constraints) {
44 | constraint.updateExisting = self.updateExisting;
45 | [constraint install];
46 | }
47 | [self.constraints removeAllObjects];
48 | return constraints;
49 | }
50 |
51 | #pragma mark - MASConstraintDelegate
52 |
53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
54 | NSUInteger index = [self.constraints indexOfObject:constraint];
55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint];
57 | }
58 |
59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute];
61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute];
62 | if ([constraint isKindOfClass:MASViewConstraint.class]) {
63 | //replace with composite constraint
64 | NSArray *children = @[constraint, newConstraint];
65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
66 | compositeConstraint.delegate = self;
67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint];
68 | return compositeConstraint;
69 | }
70 | if (!constraint) {
71 | newConstraint.delegate = self;
72 | [self.constraints addObject:newConstraint];
73 | }
74 | return newConstraint;
75 | }
76 |
77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading
79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX
80 | | MASAttributeCenterY | MASAttributeBaseline
81 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
82 | | MASAttributeFirstBaseline | MASAttributeLastBaseline
83 | #endif
84 | #if TARGET_OS_IPHONE || TARGET_OS_TV
85 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin
86 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins
87 | | MASAttributeCenterYWithinMargins
88 | #endif
89 | );
90 |
91 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)");
92 |
93 | NSMutableArray *attributes = [NSMutableArray array];
94 |
95 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left];
96 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right];
97 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top];
98 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom];
99 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading];
100 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing];
101 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width];
102 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height];
103 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX];
104 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY];
105 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline];
106 |
107 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
108 |
109 | if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline];
110 | if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline];
111 |
112 | #endif
113 |
114 | #if TARGET_OS_IPHONE || TARGET_OS_TV
115 |
116 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin];
117 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin];
118 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin];
119 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin];
120 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin];
121 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin];
122 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins];
123 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins];
124 |
125 | #endif
126 |
127 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count];
128 |
129 | for (MASViewAttribute *a in attributes) {
130 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]];
131 | }
132 |
133 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
134 | constraint.delegate = self;
135 | [self.constraints addObject:constraint];
136 | return constraint;
137 | }
138 |
139 | #pragma mark - standard Attributes
140 |
141 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
142 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute];
143 | }
144 |
145 | - (MASConstraint *)left {
146 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
147 | }
148 |
149 | - (MASConstraint *)top {
150 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
151 | }
152 |
153 | - (MASConstraint *)right {
154 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
155 | }
156 |
157 | - (MASConstraint *)bottom {
158 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
159 | }
160 |
161 | - (MASConstraint *)leading {
162 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
163 | }
164 |
165 | - (MASConstraint *)trailing {
166 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
167 | }
168 |
169 | - (MASConstraint *)width {
170 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
171 | }
172 |
173 | - (MASConstraint *)height {
174 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
175 | }
176 |
177 | - (MASConstraint *)centerX {
178 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
179 | }
180 |
181 | - (MASConstraint *)centerY {
182 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
183 | }
184 |
185 | - (MASConstraint *)baseline {
186 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
187 | }
188 |
189 | - (MASConstraint *(^)(MASAttribute))attributes {
190 | return ^(MASAttribute attrs){
191 | return [self addConstraintWithAttributes:attrs];
192 | };
193 | }
194 |
195 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
196 |
197 | - (MASConstraint *)firstBaseline {
198 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
199 | }
200 |
201 | - (MASConstraint *)lastBaseline {
202 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
203 | }
204 |
205 | #endif
206 |
207 |
208 | #if TARGET_OS_IPHONE || TARGET_OS_TV
209 |
210 | - (MASConstraint *)leftMargin {
211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
212 | }
213 |
214 | - (MASConstraint *)rightMargin {
215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
216 | }
217 |
218 | - (MASConstraint *)topMargin {
219 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
220 | }
221 |
222 | - (MASConstraint *)bottomMargin {
223 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
224 | }
225 |
226 | - (MASConstraint *)leadingMargin {
227 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
228 | }
229 |
230 | - (MASConstraint *)trailingMargin {
231 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
232 | }
233 |
234 | - (MASConstraint *)centerXWithinMargins {
235 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
236 | }
237 |
238 | - (MASConstraint *)centerYWithinMargins {
239 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
240 | }
241 |
242 | #endif
243 |
244 |
245 | #pragma mark - composite Attributes
246 |
247 | - (MASConstraint *)edges {
248 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom];
249 | }
250 |
251 | - (MASConstraint *)size {
252 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight];
253 | }
254 |
255 | - (MASConstraint *)center {
256 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY];
257 | }
258 |
259 | #pragma mark - grouping
260 |
261 | - (MASConstraint *(^)(dispatch_block_t group))group {
262 | return ^id(dispatch_block_t group) {
263 | NSInteger previousCount = self.constraints.count;
264 | group();
265 |
266 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)];
267 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
268 | constraint.delegate = self;
269 | return constraint;
270 | };
271 | }
272 |
273 | @end
274 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/MASViewConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewConstraint.h"
10 | #import "MASConstraint+Private.h"
11 | #import "MASCompositeConstraint.h"
12 | #import "MASLayoutConstraint.h"
13 | #import "View+MASAdditions.h"
14 | #import
15 |
16 | @interface MAS_VIEW (MASConstraints)
17 |
18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints;
19 |
20 | @end
21 |
22 | @implementation MAS_VIEW (MASConstraints)
23 |
24 | static char kInstalledConstraintsKey;
25 |
26 | - (NSMutableSet *)mas_installedConstraints {
27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey);
28 | if (!constraints) {
29 | constraints = [NSMutableSet set];
30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
31 | }
32 | return constraints;
33 | }
34 |
35 | @end
36 |
37 |
38 | @interface MASViewConstraint ()
39 |
40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute;
41 | @property (nonatomic, weak) MAS_VIEW *installedView;
42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint;
43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation;
44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority;
45 | @property (nonatomic, assign) CGFloat layoutMultiplier;
46 | @property (nonatomic, assign) CGFloat layoutConstant;
47 | @property (nonatomic, assign) BOOL hasLayoutRelation;
48 | @property (nonatomic, strong) id mas_key;
49 | @property (nonatomic, assign) BOOL useAnimator;
50 |
51 | @end
52 |
53 | @implementation MASViewConstraint
54 |
55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute {
56 | self = [super init];
57 | if (!self) return nil;
58 |
59 | _firstViewAttribute = firstViewAttribute;
60 | self.layoutPriority = MASLayoutPriorityRequired;
61 | self.layoutMultiplier = 1;
62 |
63 | return self;
64 | }
65 |
66 | #pragma mark - NSCoping
67 |
68 | - (id)copyWithZone:(NSZone __unused *)zone {
69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute];
70 | constraint.layoutConstant = self.layoutConstant;
71 | constraint.layoutRelation = self.layoutRelation;
72 | constraint.layoutPriority = self.layoutPriority;
73 | constraint.layoutMultiplier = self.layoutMultiplier;
74 | constraint.delegate = self.delegate;
75 | return constraint;
76 | }
77 |
78 | #pragma mark - Public
79 |
80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view {
81 | return [view.mas_installedConstraints allObjects];
82 | }
83 |
84 | #pragma mark - Private
85 |
86 | - (void)setLayoutConstant:(CGFloat)layoutConstant {
87 | _layoutConstant = layoutConstant;
88 |
89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
90 | if (self.useAnimator) {
91 | [self.layoutConstraint.animator setConstant:layoutConstant];
92 | } else {
93 | self.layoutConstraint.constant = layoutConstant;
94 | }
95 | #else
96 | self.layoutConstraint.constant = layoutConstant;
97 | #endif
98 | }
99 |
100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation {
101 | _layoutRelation = layoutRelation;
102 | self.hasLayoutRelation = YES;
103 | }
104 |
105 | - (BOOL)supportsActiveProperty {
106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)];
107 | }
108 |
109 | - (BOOL)isActive {
110 | BOOL active = YES;
111 | if ([self supportsActiveProperty]) {
112 | active = [self.layoutConstraint isActive];
113 | }
114 |
115 | return active;
116 | }
117 |
118 | - (BOOL)hasBeenInstalled {
119 | return (self.layoutConstraint != nil) && [self isActive];
120 | }
121 |
122 | - (void)setSecondViewAttribute:(id)secondViewAttribute {
123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) {
124 | [self setLayoutConstantWithValue:secondViewAttribute];
125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {
126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];
127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
128 | _secondViewAttribute = secondViewAttribute;
129 | } else {
130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
131 | }
132 | }
133 |
134 | #pragma mark - NSLayoutConstraint multiplier proxies
135 |
136 | - (MASConstraint * (^)(CGFloat))multipliedBy {
137 | return ^id(CGFloat multiplier) {
138 | NSAssert(!self.hasBeenInstalled,
139 | @"Cannot modify constraint multiplier after it has been installed");
140 |
141 | self.layoutMultiplier = multiplier;
142 | return self;
143 | };
144 | }
145 |
146 |
147 | - (MASConstraint * (^)(CGFloat))dividedBy {
148 | return ^id(CGFloat divider) {
149 | NSAssert(!self.hasBeenInstalled,
150 | @"Cannot modify constraint multiplier after it has been installed");
151 |
152 | self.layoutMultiplier = 1.0/divider;
153 | return self;
154 | };
155 | }
156 |
157 | #pragma mark - MASLayoutPriority proxy
158 |
159 | - (MASConstraint * (^)(MASLayoutPriority))priority {
160 | return ^id(MASLayoutPriority priority) {
161 | NSAssert(!self.hasBeenInstalled,
162 | @"Cannot modify constraint priority after it has been installed");
163 |
164 | self.layoutPriority = priority;
165 | return self;
166 | };
167 | }
168 |
169 | #pragma mark - NSLayoutRelation proxy
170 |
171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
172 | return ^id(id attribute, NSLayoutRelation relation) {
173 | if ([attribute isKindOfClass:NSArray.class]) {
174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation");
175 | NSMutableArray *children = NSMutableArray.new;
176 | for (id attr in attribute) {
177 | MASViewConstraint *viewConstraint = [self copy];
178 | viewConstraint.layoutRelation = relation;
179 | viewConstraint.secondViewAttribute = attr;
180 | [children addObject:viewConstraint];
181 | }
182 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
183 | compositeConstraint.delegate = self.delegate;
184 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint];
185 | return compositeConstraint;
186 | } else {
187 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation");
188 | self.layoutRelation = relation;
189 | self.secondViewAttribute = attribute;
190 | return self;
191 | }
192 | };
193 | }
194 |
195 | #pragma mark - Semantic properties
196 |
197 | - (MASConstraint *)with {
198 | return self;
199 | }
200 |
201 | - (MASConstraint *)and {
202 | return self;
203 | }
204 |
205 | #pragma mark - attribute chaining
206 |
207 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
208 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation");
209 |
210 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
211 | }
212 |
213 | #pragma mark - Animator proxy
214 |
215 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
216 |
217 | - (MASConstraint *)animator {
218 | self.useAnimator = YES;
219 | return self;
220 | }
221 |
222 | #endif
223 |
224 | #pragma mark - debug helpers
225 |
226 | - (MASConstraint * (^)(id))key {
227 | return ^id(id key) {
228 | self.mas_key = key;
229 | return self;
230 | };
231 | }
232 |
233 | #pragma mark - NSLayoutConstraint constant setters
234 |
235 | - (void)setInsets:(MASEdgeInsets)insets {
236 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
237 | switch (layoutAttribute) {
238 | case NSLayoutAttributeLeft:
239 | case NSLayoutAttributeLeading:
240 | self.layoutConstant = insets.left;
241 | break;
242 | case NSLayoutAttributeTop:
243 | self.layoutConstant = insets.top;
244 | break;
245 | case NSLayoutAttributeBottom:
246 | self.layoutConstant = -insets.bottom;
247 | break;
248 | case NSLayoutAttributeRight:
249 | case NSLayoutAttributeTrailing:
250 | self.layoutConstant = -insets.right;
251 | break;
252 | default:
253 | break;
254 | }
255 | }
256 |
257 | - (void)setOffset:(CGFloat)offset {
258 | self.layoutConstant = offset;
259 | }
260 |
261 | - (void)setSizeOffset:(CGSize)sizeOffset {
262 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
263 | switch (layoutAttribute) {
264 | case NSLayoutAttributeWidth:
265 | self.layoutConstant = sizeOffset.width;
266 | break;
267 | case NSLayoutAttributeHeight:
268 | self.layoutConstant = sizeOffset.height;
269 | break;
270 | default:
271 | break;
272 | }
273 | }
274 |
275 | - (void)setCenterOffset:(CGPoint)centerOffset {
276 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
277 | switch (layoutAttribute) {
278 | case NSLayoutAttributeCenterX:
279 | self.layoutConstant = centerOffset.x;
280 | break;
281 | case NSLayoutAttributeCenterY:
282 | self.layoutConstant = centerOffset.y;
283 | break;
284 | default:
285 | break;
286 | }
287 | }
288 |
289 | #pragma mark - MASConstraint
290 |
291 | - (void)activate {
292 | [self install];
293 | }
294 |
295 | - (void)deactivate {
296 | [self uninstall];
297 | }
298 |
299 | - (void)install {
300 | if (self.hasBeenInstalled) {
301 | return;
302 | }
303 |
304 | if ([self supportsActiveProperty] && self.layoutConstraint) {
305 | self.layoutConstraint.active = YES;
306 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self];
307 | return;
308 | }
309 |
310 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item;
311 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute;
312 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item;
313 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute;
314 |
315 | // alignment attributes must have a secondViewAttribute
316 | // therefore we assume that is refering to superview
317 | // eg make.left.equalTo(@10)
318 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) {
319 | secondLayoutItem = self.firstViewAttribute.view.superview;
320 | secondLayoutAttribute = firstLayoutAttribute;
321 | }
322 |
323 | MASLayoutConstraint *layoutConstraint
324 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem
325 | attribute:firstLayoutAttribute
326 | relatedBy:self.layoutRelation
327 | toItem:secondLayoutItem
328 | attribute:secondLayoutAttribute
329 | multiplier:self.layoutMultiplier
330 | constant:self.layoutConstant];
331 |
332 | layoutConstraint.priority = self.layoutPriority;
333 | layoutConstraint.mas_key = self.mas_key;
334 |
335 | if (self.secondViewAttribute.view) {
336 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];
337 | NSAssert(closestCommonSuperview,
338 | @"couldn't find a common superview for %@ and %@",
339 | self.firstViewAttribute.view, self.secondViewAttribute.view);
340 | self.installedView = closestCommonSuperview;
341 | } else if (self.firstViewAttribute.isSizeAttribute) {
342 | self.installedView = self.firstViewAttribute.view;
343 | } else {
344 | self.installedView = self.firstViewAttribute.view.superview;
345 | }
346 |
347 |
348 | MASLayoutConstraint *existingConstraint = nil;
349 | if (self.updateExisting) {
350 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint];
351 | }
352 | if (existingConstraint) {
353 | // just update the constant
354 | existingConstraint.constant = layoutConstraint.constant;
355 | self.layoutConstraint = existingConstraint;
356 | } else {
357 | [self.installedView addConstraint:layoutConstraint];
358 | self.layoutConstraint = layoutConstraint;
359 | [firstLayoutItem.mas_installedConstraints addObject:self];
360 | }
361 | }
362 |
363 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint {
364 | // check if any constraints are the same apart from the only mutable property constant
365 |
366 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints
367 | // and they are likely to be added first.
368 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) {
369 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue;
370 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue;
371 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue;
372 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue;
373 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue;
374 | if (existingConstraint.relation != layoutConstraint.relation) continue;
375 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue;
376 | if (existingConstraint.priority != layoutConstraint.priority) continue;
377 |
378 | return (id)existingConstraint;
379 | }
380 | return nil;
381 | }
382 |
383 | - (void)uninstall {
384 | if ([self supportsActiveProperty]) {
385 | self.layoutConstraint.active = NO;
386 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
387 | return;
388 | }
389 |
390 | [self.installedView removeConstraint:self.layoutConstraint];
391 | self.layoutConstraint = nil;
392 | self.installedView = nil;
393 |
394 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
395 | }
396 |
397 | @end
398 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 TARGET_OS_IPHONE || TARGET_OS_TV
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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 TARGET_OS_IPHONE || TARGET_OS_TV
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 | /**
56 | * a key to associate with this view
57 | */
58 | @property (nonatomic, strong) id mas_key;
59 |
60 | /**
61 | * Finds the closest common superview between this view and another view
62 | *
63 | * @param view other view
64 | *
65 | * @return returns nil if common superview could not be found
66 | */
67 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
68 |
69 | /**
70 | * Creates a MASConstraintMaker with the callee view.
71 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing
72 | *
73 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
74 | *
75 | * @return Array of created MASConstraints
76 | */
77 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block;
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 | * If an existing constraint exists then it will be updated instead.
83 | *
84 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
85 | *
86 | * @return Array of created/updated MASConstraints
87 | */
88 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block;
89 |
90 | /**
91 | * Creates a MASConstraintMaker with the callee view.
92 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
93 | * All constraints previously installed for the view will be removed.
94 | *
95 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
96 | *
97 | * @return Array of created/updated MASConstraints
98 | */
99 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block;
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 TARGET_OS_IPHONE || TARGET_OS_TV
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 | #pragma mark - associated properties
138 |
139 | - (id)mas_key {
140 | return objc_getAssociatedObject(self, @selector(mas_key));
141 | }
142 |
143 | - (void)setMas_key:(id)key {
144 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
145 | }
146 |
147 | #pragma mark - heirachy
148 |
149 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
150 | MAS_VIEW *closestCommonSuperview = nil;
151 |
152 | MAS_VIEW *secondViewSuperview = view;
153 | while (!closestCommonSuperview && secondViewSuperview) {
154 | MAS_VIEW *firstViewSuperview = self;
155 | while (!closestCommonSuperview && firstViewSuperview) {
156 | if (secondViewSuperview == firstViewSuperview) {
157 | closestCommonSuperview = secondViewSuperview;
158 | }
159 | firstViewSuperview = firstViewSuperview.superview;
160 | }
161 | secondViewSuperview = secondViewSuperview.superview;
162 | }
163 | return closestCommonSuperview;
164 | }
165 |
166 | @end
167 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 TARGET_OS_IPHONE || TARGET_OS_TV
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 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
53 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
54 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
55 |
56 | @end
57 |
58 | #define MAS_ATTR_FORWARD(attr) \
59 | - (MASViewAttribute *)attr { \
60 | return [self mas_##attr]; \
61 | }
62 |
63 | @implementation MAS_VIEW (MASShorthandAdditions)
64 |
65 | MAS_ATTR_FORWARD(top);
66 | MAS_ATTR_FORWARD(left);
67 | MAS_ATTR_FORWARD(bottom);
68 | MAS_ATTR_FORWARD(right);
69 | MAS_ATTR_FORWARD(leading);
70 | MAS_ATTR_FORWARD(trailing);
71 | MAS_ATTR_FORWARD(width);
72 | MAS_ATTR_FORWARD(height);
73 | MAS_ATTR_FORWARD(centerX);
74 | MAS_ATTR_FORWARD(centerY);
75 | MAS_ATTR_FORWARD(baseline);
76 |
77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
78 |
79 | MAS_ATTR_FORWARD(firstBaseline);
80 | MAS_ATTR_FORWARD(lastBaseline);
81 |
82 | #endif
83 |
84 | #if TARGET_OS_IPHONE || TARGET_OS_TV
85 |
86 | MAS_ATTR_FORWARD(leftMargin);
87 | MAS_ATTR_FORWARD(rightMargin);
88 | MAS_ATTR_FORWARD(topMargin);
89 | MAS_ATTR_FORWARD(bottomMargin);
90 | MAS_ATTR_FORWARD(leadingMargin);
91 | MAS_ATTR_FORWARD(trailingMargin);
92 | MAS_ATTR_FORWARD(centerXWithinMargins);
93 | MAS_ATTR_FORWARD(centerYWithinMargins);
94 |
95 | #endif
96 |
97 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
98 | return [self mas_attribute];
99 | }
100 |
101 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
102 | return [self mas_makeConstraints:block];
103 | }
104 |
105 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
106 | return [self mas_updateConstraints:block];
107 | }
108 |
109 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
110 | return [self mas_remakeConstraints:block];
111 | }
112 |
113 | @end
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/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 |
--------------------------------------------------------------------------------
/MainProject/Pods/Masonry/README.md:
--------------------------------------------------------------------------------
1 | #Masonry [](https://travis-ci.org/SnapKit/Masonry) [](https://coveralls.io/r/SnapKit/Masonry) [](https://github.com/Carthage/Carthage) 
2 |
3 | **Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're using Swift in your project, we recommend using [SnapKit](https://github.com/SnapKit/SnapKit) as it provides better type safety with a simpler API.**
4 |
5 | Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Masonry has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable.
6 | Masonry supports iOS and Mac OS X.
7 |
8 | For examples take a look at the **Masonry iOS Examples** project in the Masonry workspace. You will need to run `pod install` after downloading.
9 |
10 | ## What's wrong with NSLayoutConstraints?
11 |
12 | Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive.
13 | Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side
14 | ```obj-c
15 | UIView *superview = self.view;
16 |
17 | UIView *view1 = [[UIView alloc] init];
18 | view1.translatesAutoresizingMaskIntoConstraints = NO;
19 | view1.backgroundColor = [UIColor greenColor];
20 | [superview addSubview:view1];
21 |
22 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
23 |
24 | [superview addConstraints:@[
25 |
26 | //view1 constraints
27 | [NSLayoutConstraint constraintWithItem:view1
28 | attribute:NSLayoutAttributeTop
29 | relatedBy:NSLayoutRelationEqual
30 | toItem:superview
31 | attribute:NSLayoutAttributeTop
32 | multiplier:1.0
33 | constant:padding.top],
34 |
35 | [NSLayoutConstraint constraintWithItem:view1
36 | attribute:NSLayoutAttributeLeft
37 | relatedBy:NSLayoutRelationEqual
38 | toItem:superview
39 | attribute:NSLayoutAttributeLeft
40 | multiplier:1.0
41 | constant:padding.left],
42 |
43 | [NSLayoutConstraint constraintWithItem:view1
44 | attribute:NSLayoutAttributeBottom
45 | relatedBy:NSLayoutRelationEqual
46 | toItem:superview
47 | attribute:NSLayoutAttributeBottom
48 | multiplier:1.0
49 | constant:-padding.bottom],
50 |
51 | [NSLayoutConstraint constraintWithItem:view1
52 | attribute:NSLayoutAttributeRight
53 | relatedBy:NSLayoutRelationEqual
54 | toItem:superview
55 | attribute:NSLayoutAttributeRight
56 | multiplier:1
57 | constant:-padding.right],
58 |
59 | ]];
60 | ```
61 | Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views.
62 | Another option is to use Visual Format Language (VFL), which is a bit less long winded.
63 | However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint constraintsWithVisualFormat:` returns an array.
64 |
65 | ## Prepare to meet your Maker!
66 |
67 | Heres the same constraints created using MASConstraintMaker
68 |
69 | ```obj-c
70 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
71 |
72 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
73 | make.top.equalTo(superview.mas_top).with.offset(padding.top); //with is an optional semantic filler
74 | make.left.equalTo(superview.mas_left).with.offset(padding.left);
75 | make.bottom.equalTo(superview.mas_bottom).with.offset(-padding.bottom);
76 | make.right.equalTo(superview.mas_right).with.offset(-padding.right);
77 | }];
78 | ```
79 | Or even shorter
80 |
81 | ```obj-c
82 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
83 | make.edges.equalTo(superview).with.insets(padding);
84 | }];
85 | ```
86 |
87 | Also note in the first example we had to add the constraints to the superview `[superview addConstraints:...`.
88 | Masonry however will automagically add constraints to the appropriate view.
89 |
90 | Masonry will also call `view1.translatesAutoresizingMaskIntoConstraints = NO;` for you.
91 |
92 | ## Not all things are created equal
93 |
94 | > `.equalTo` equivalent to **NSLayoutRelationEqual**
95 |
96 | > `.lessThanOrEqualTo` equivalent to **NSLayoutRelationLessThanOrEqual**
97 |
98 | > `.greaterThanOrEqualTo` equivalent to **NSLayoutRelationGreaterThanOrEqual**
99 |
100 | These three equality constraints accept one argument which can be any of the following:
101 |
102 | #### 1. MASViewAttribute
103 |
104 | ```obj-c
105 | make.centerX.lessThanOrEqualTo(view2.mas_left);
106 | ```
107 |
108 | MASViewAttribute | NSLayoutAttribute
109 | ------------------------- | --------------------------
110 | view.mas_left | NSLayoutAttributeLeft
111 | view.mas_right | NSLayoutAttributeRight
112 | view.mas_top | NSLayoutAttributeTop
113 | view.mas_bottom | NSLayoutAttributeBottom
114 | view.mas_leading | NSLayoutAttributeLeading
115 | view.mas_trailing | NSLayoutAttributeTrailing
116 | view.mas_width | NSLayoutAttributeWidth
117 | view.mas_height | NSLayoutAttributeHeight
118 | view.mas_centerX | NSLayoutAttributeCenterX
119 | view.mas_centerY | NSLayoutAttributeCenterY
120 | view.mas_baseline | NSLayoutAttributeBaseline
121 |
122 | #### 2. UIView/NSView
123 |
124 | if you want view.left to be greater than or equal to label.left :
125 | ```obj-c
126 | //these two constraints are exactly the same
127 | make.left.greaterThanOrEqualTo(label);
128 | make.left.greaterThanOrEqualTo(label.mas_left);
129 | ```
130 |
131 | #### 3. NSNumber
132 |
133 | Auto Layout allows width and height to be set to constant values.
134 | if you want to set view to have a minimum and maximum width you could pass a number to the equality blocks:
135 | ```obj-c
136 | //width >= 200 && width <= 400
137 | make.width.greaterThanOrEqualTo(@200);
138 | make.width.lessThanOrEqualTo(@400)
139 | ```
140 |
141 | However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values.
142 | So if you pass a NSNumber for these attributes Masonry will turn these into constraints relative to the view’s superview ie:
143 | ```obj-c
144 | //creates view.left = view.superview.left + 10
145 | make.left.lessThanOrEqualTo(@10)
146 | ```
147 |
148 | Instead of using NSNumber, you can use primitives and structs to build your constraints, like so:
149 | ```obj-c
150 | make.top.mas_equalTo(42);
151 | make.height.mas_equalTo(20);
152 | make.size.mas_equalTo(CGSizeMake(50, 100));
153 | make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0));
154 | make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0));
155 | ```
156 |
157 | By default, macros which support [autoboxing](https://en.wikipedia.org/wiki/Autoboxing#Autoboxing) are prefixed with `mas_`. Unprefixed versions are available by defining `MAS_SHORTHAND_GLOBALS` before importing Masonry.
158 |
159 | #### 4. NSArray
160 |
161 | An array of a mixture of any of the previous types
162 | ```obj-c
163 | make.height.equalTo(@[view1.mas_height, view2.mas_height]);
164 | make.height.equalTo(@[view1, view2]);
165 | make.left.equalTo(@[view1, @100, view3.right]);
166 | ````
167 |
168 | ## Learn to prioritize
169 |
170 | > `.priority` allows you to specify an exact priority
171 |
172 | > `.priorityHigh` equivalent to **UILayoutPriorityDefaultHigh**
173 |
174 | > `.priorityMedium` is half way between high and low
175 |
176 | > `.priorityLow` equivalent to **UILayoutPriorityDefaultLow**
177 |
178 | Priorities are can be tacked on to the end of a constraint chain like so:
179 | ```obj-c
180 | make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow();
181 |
182 | make.top.equalTo(label.mas_top).with.priority(600);
183 | ```
184 |
185 | ## Composition, composition, composition
186 |
187 | Masonry also gives you a few convenience methods which create multiple constraints at the same time. These are called MASCompositeConstraints
188 |
189 | #### edges
190 |
191 | ```obj-c
192 | // make top, left, bottom, right equal view2
193 | make.edges.equalTo(view2);
194 |
195 | // make top = superview.top + 5, left = superview.left + 10,
196 | // bottom = superview.bottom - 15, right = superview.right - 20
197 | make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20))
198 | ```
199 |
200 | #### size
201 |
202 | ```obj-c
203 | // make width and height greater than or equal to titleLabel
204 | make.size.greaterThanOrEqualTo(titleLabel)
205 |
206 | // make width = superview.width + 100, height = superview.height - 50
207 | make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50))
208 | ```
209 |
210 | #### center
211 | ```obj-c
212 | // make centerX and centerY = button1
213 | make.center.equalTo(button1)
214 |
215 | // make centerX = superview.centerX - 5, centerY = superview.centerY + 10
216 | make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10))
217 | ```
218 |
219 | You can chain view attributes for increased readability:
220 |
221 | ```obj-c
222 | // All edges but the top should equal those of the superview
223 | make.left.right.and.bottom.equalTo(superview);
224 | make.top.equalTo(otherView);
225 | ```
226 |
227 | ## Hold on for dear life
228 |
229 | Sometimes you need modify existing constraints in order to animate or remove/replace constraints.
230 | In Masonry there are a few different approaches to updating constraints.
231 |
232 | #### 1. References
233 | You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property.
234 | You could also reference multiple constraints by storing them away in an array.
235 |
236 | ```obj-c
237 | // in public/private interface
238 | @property (nonatomic, strong) MASConstraint *topConstraint;
239 |
240 | ...
241 |
242 | // when making constraints
243 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
244 | self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top);
245 | make.left.equalTo(superview.mas_left).with.offset(padding.left);
246 | }];
247 |
248 | ...
249 | // then later you can call
250 | [self.topConstraint uninstall];
251 | ```
252 |
253 | #### 2. mas_updateConstraints
254 | Alternatively if you are only updating the constant value of the constraint you can use the convience method `mas_updateConstraints` instead of `mas_makeConstraints`
255 |
256 | ```obj-c
257 | // this is Apple's recommended place for adding/updating constraints
258 | // this method can get called multiple times in response to setNeedsUpdateConstraints
259 | // which can be called by UIKit internally or in your code if you need to trigger an update to your constraints
260 | - (void)updateConstraints {
261 | [self.growingButton mas_updateConstraints:^(MASConstraintMaker *make) {
262 | make.center.equalTo(self);
263 | make.width.equalTo(@(self.buttonSize.width)).priorityLow();
264 | make.height.equalTo(@(self.buttonSize.height)).priorityLow();
265 | make.width.lessThanOrEqualTo(self);
266 | make.height.lessThanOrEqualTo(self);
267 | }];
268 |
269 | //according to apple super should be called at end of method
270 | [super updateConstraints];
271 | }
272 | ```
273 |
274 | ### 3. mas_remakeConstraints
275 | `mas_updateConstraints` is useful for updating a set of constraints, but doing anything beyond updating constant values can get exhausting. That's where `mas_remakeConstraints` comes in.
276 |
277 | `mas_remakeConstraints` is similar to `mas_updateConstraints`, but instead of updating constant values, it will remove all of its constraints before installing them again. This lets you provide different constraints without having to keep around references to ones which you want to remove.
278 |
279 | ```obj-c
280 | - (void)changeButtonPosition {
281 | [self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
282 | make.size.equalTo(self.buttonSize);
283 |
284 | if (topLeft) {
285 | make.top.and.left.offset(10);
286 | } else {
287 | make.bottom.and.right.offset(-10);
288 | }
289 | }];
290 | }
291 | ```
292 |
293 | You can find more detailed examples of all three approaches in the **Masonry iOS Examples** project.
294 |
295 | ## When the ^&*!@ hits the fan!
296 |
297 | Laying out your views doesn't always goto plan. So when things literally go pear shaped, you don't want to be looking at console output like this:
298 |
299 | ```obj-c
300 | Unable to simultaneously satisfy constraints.....blah blah blah....
301 | (
302 | "=5000)]>",
303 | "",
304 | "",
305 | ""
306 | )
307 |
308 | Will attempt to recover by breaking constraint
309 | =5000)]>
310 | ```
311 |
312 | Masonry adds a category to NSLayoutConstraint which overrides the default implementation of `- (NSString *)description`.
313 | Now you can give meaningful names to views and constraints, and also easily pick out the constraints created by Masonry.
314 |
315 | which means your console output can now look like this:
316 |
317 | ```obj-c
318 | Unable to simultaneously satisfy constraints......blah blah blah....
319 | (
320 | "",
321 | "= 5000>",
322 | "",
323 | ""
324 | )
325 |
326 | Will attempt to recover by breaking constraint
327 | = 5000>
328 | ```
329 |
330 | For an example of how to set this up take a look at the **Masonry iOS Examples** project in the Masonry workspace.
331 |
332 | ## Where should I create my constraints?
333 |
334 | ```objc
335 | @implementation DIYCustomView
336 |
337 | - (id)init {
338 | self = [super init];
339 | if (!self) return nil;
340 |
341 | // --- Create your views here ---
342 | self.button = [[UIButton alloc] init];
343 |
344 | return self;
345 | }
346 |
347 | // tell UIKit that you are using AutoLayout
348 | + (BOOL)requiresConstraintBasedLayout {
349 | return YES;
350 | }
351 |
352 | // this is Apple's recommended place for adding/updating constraints
353 | - (void)updateConstraints {
354 |
355 | // --- remake/update constraints here
356 | [self.button remakeConstraints:^(MASConstraintMaker *make) {
357 | make.width.equalTo(@(self.buttonSize.width));
358 | make.height.equalTo(@(self.buttonSize.height));
359 | }];
360 |
361 | //according to apple super should be called at end of method
362 | [super updateConstraints];
363 | }
364 |
365 | - (void)didTapButton:(UIButton *)button {
366 | // --- Do your changes ie change variables that affect your layout etc ---
367 | self.buttonSize = CGSize(200, 200);
368 |
369 | // tell constraints they need updating
370 | [self setNeedsUpdateConstraints];
371 | }
372 |
373 | @end
374 | ```
375 |
376 | ## Installation
377 | Use the [orsome](http://www.youtube.com/watch?v=YaIZF8uUTtk) [CocoaPods](http://github.com/CocoaPods/CocoaPods).
378 |
379 | In your Podfile
380 | >`pod 'Masonry'`
381 |
382 | If you want to use masonry without all those pesky 'mas_' prefixes. Add #define MAS_SHORTHAND to your prefix.pch before importing Masonry
383 | >`#define MAS_SHORTHAND`
384 |
385 | Get busy Masoning
386 | >`#import "Masonry.h"`
387 |
388 | ## Code Snippets
389 |
390 | Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your masonry blocks at lightning speed!
391 |
392 | `mas_make` -> `[ mas_makeConstraints:^(MASConstraintMaker *make){}];`
393 |
394 | `mas_update` -> `[ mas_updateConstraints:^(MASConstraintMaker *make){}];`
395 |
396 | `mas_remake` -> `[ mas_remakeConstraints:^(MASConstraintMaker *make){}];`
397 |
398 | ## Features
399 | * Not limited to subset of Auto Layout. Anything NSLayoutConstraint can do, Masonry can do too!
400 | * Great debug support, give your views and constraints meaningful names.
401 | * Constraints read like sentences.
402 | * No crazy macro magic. Masonry won't pollute the global namespace with macros.
403 | * Not string or dictionary based and hence you get compile time checking.
404 |
405 | ## TODO
406 | * Eye candy
407 | * Mac example project
408 | * More tests and examples
409 |
410 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/HomePageModule/HomePageModule-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_HomePageModule : NSObject
3 | @end
4 | @implementation PodsDummy_HomePageModule
5 | @end
6 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/HomePageModule/HomePageModule-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/HomePageModule/HomePageModule.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/HomePageModule
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/HomePageModule" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MGJRouter"
5 | OTHER_LDFLAGS = -framework "UIKit"
6 | PODS_BUILD_DIR = $BUILD_DIR
7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_ROOT = ${SRCROOT}
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/MGJRouter/MGJRouter-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_MGJRouter : NSObject
3 | @end
4 | @implementation PodsDummy_MGJRouter
5 | @end
6 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/MGJRouter/MGJRouter-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/MGJRouter/MGJRouter.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/MGJRouter
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MGJRouter" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | PODS_BUILD_DIR = $BUILD_DIR
5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
8 | SKIP_INSTALL = YES
9 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Masonry/Masonry-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Masonry : NSObject
3 | @end
4 | @implementation PodsDummy_Masonry
5 | @end
6 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Masonry/Masonry-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Masonry/Masonry.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Masonry
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit"
5 | PODS_BUILD_DIR = $BUILD_DIR
6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 | PODS_ROOT = ${SRCROOT}
8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
9 | SKIP_INSTALL = YES
10 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## HomePageModule
5 |
6 | The MIT License (MIT)
7 |
8 | Copyright (c) 2016 刘小壮
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy of
11 | this software and associated documentation files (the "Software"), to deal in
12 | the Software without restriction, including without limitation the rights to
13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 | the Software, and to permit persons to whom the Software is furnished to do so,
15 | subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in all
18 | copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 |
27 |
28 | ## MGJRouter
29 |
30 | The MIT License (MIT)
31 |
32 | Copyright (c) 2015 mogujie
33 |
34 | Permission is hereby granted, free of charge, to any person obtaining a copy
35 | of this software and associated documentation files (the "Software"), to deal
36 | in the Software without restriction, including without limitation the rights
37 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38 | copies of the Software, and to permit persons to whom the Software is
39 | furnished to do so, subject to the following conditions:
40 |
41 | The above copyright notice and this permission notice shall be included in all
42 | copies or substantial portions of the Software.
43 |
44 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50 | SOFTWARE.
51 |
52 |
53 |
54 | ## Masonry
55 |
56 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
57 |
58 | Permission is hereby granted, free of charge, to any person obtaining a copy
59 | of this software and associated documentation files (the "Software"), to deal
60 | in the Software without restriction, including without limitation the rights
61 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62 | copies of the Software, and to permit persons to whom the Software is
63 | furnished to do so, subject to the following conditions:
64 |
65 | The above copyright notice and this permission notice shall be included in
66 | all copies or substantial portions of the Software.
67 |
68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74 | THE SOFTWARE.
75 |
76 | ## UserCenterModule
77 |
78 | The MIT License (MIT)
79 |
80 | Copyright (c) 2016 刘小壮
81 |
82 | Permission is hereby granted, free of charge, to any person obtaining a copy of
83 | this software and associated documentation files (the "Software"), to deal in
84 | the Software without restriction, including without limitation the rights to
85 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
86 | the Software, and to permit persons to whom the Software is furnished to do so,
87 | subject to the following conditions:
88 |
89 | The above copyright notice and this permission notice shall be included in all
90 | copies or substantial portions of the Software.
91 |
92 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
93 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
94 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
95 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
96 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
97 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
98 |
99 | Generated by CocoaPods - https://cocoapods.org
100 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | The MIT License (MIT)
18 |
19 | Copyright (c) 2016 刘小壮
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a copy of
22 | this software and associated documentation files (the "Software"), to deal in
23 | the Software without restriction, including without limitation the rights to
24 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
25 | the Software, and to permit persons to whom the Software is furnished to do so,
26 | subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in all
29 | copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
33 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
34 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
35 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 |
38 | License
39 | MIT
40 | Title
41 | HomePageModule
42 | Type
43 | PSGroupSpecifier
44 |
45 |
46 | FooterText
47 | The MIT License (MIT)
48 |
49 | Copyright (c) 2015 mogujie
50 |
51 | Permission is hereby granted, free of charge, to any person obtaining a copy
52 | of this software and associated documentation files (the "Software"), to deal
53 | in the Software without restriction, including without limitation the rights
54 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55 | copies of the Software, and to permit persons to whom the Software is
56 | furnished to do so, subject to the following conditions:
57 |
58 | The above copyright notice and this permission notice shall be included in all
59 | copies or substantial portions of the Software.
60 |
61 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67 | SOFTWARE.
68 |
69 |
70 | License
71 | MIT
72 | Title
73 | MGJRouter
74 | Type
75 | PSGroupSpecifier
76 |
77 |
78 | FooterText
79 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
80 |
81 | Permission is hereby granted, free of charge, to any person obtaining a copy
82 | of this software and associated documentation files (the "Software"), to deal
83 | in the Software without restriction, including without limitation the rights
84 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
85 | copies of the Software, and to permit persons to whom the Software is
86 | furnished to do so, subject to the following conditions:
87 |
88 | The above copyright notice and this permission notice shall be included in
89 | all copies or substantial portions of the Software.
90 |
91 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
97 | THE SOFTWARE.
98 | License
99 | MIT
100 | Title
101 | Masonry
102 | Type
103 | PSGroupSpecifier
104 |
105 |
106 | FooterText
107 | The MIT License (MIT)
108 |
109 | Copyright (c) 2016 刘小壮
110 |
111 | Permission is hereby granted, free of charge, to any person obtaining a copy of
112 | this software and associated documentation files (the "Software"), to deal in
113 | the Software without restriction, including without limitation the rights to
114 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
115 | the Software, and to permit persons to whom the Software is furnished to do so,
116 | subject to the following conditions:
117 |
118 | The above copyright notice and this permission notice shall be included in all
119 | copies or substantial portions of the Software.
120 |
121 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
122 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
123 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
124 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
125 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
126 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127 |
128 | License
129 | MIT
130 | Title
131 | UserCenterModule
132 | Type
133 | PSGroupSpecifier
134 |
135 |
136 | FooterText
137 | Generated by CocoaPods - https://cocoapods.org
138 | Title
139 |
140 | Type
141 | PSGroupSpecifier
142 |
143 |
144 | StringsTable
145 | Acknowledgements
146 | Title
147 | Acknowledgements
148 |
149 |
150 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_MainProject : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_MainProject
5 | @end
6 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | install_framework()
10 | {
11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
12 | local source="${BUILT_PRODUCTS_DIR}/$1"
13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
15 | elif [ -r "$1" ]; then
16 | local source="$1"
17 | fi
18 |
19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 |
21 | if [ -L "${source}" ]; then
22 | echo "Symlinked..."
23 | source="$(readlink "${source}")"
24 | fi
25 |
26 | # use filter instead of exclude so missing patterns dont' throw errors
27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
29 |
30 | local basename
31 | basename="$(basename -s .framework "$1")"
32 | binary="${destination}/${basename}.framework/${basename}"
33 | if ! [ -r "$binary" ]; then
34 | binary="${destination}/${basename}"
35 | fi
36 |
37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
39 | strip_invalid_archs "$binary"
40 | fi
41 |
42 | # Resign the code if required by the build settings to avoid unstable apps
43 | code_sign_if_enabled "${destination}/$(basename "$1")"
44 |
45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
47 | local swift_runtime_libs
48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
49 | for lib in $swift_runtime_libs; do
50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
52 | code_sign_if_enabled "${destination}/${lib}"
53 | done
54 | fi
55 | }
56 |
57 | # Signs a framework with the provided identity
58 | code_sign_if_enabled() {
59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
60 | # Use the current code_sign_identitiy
61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
64 | fi
65 | }
66 |
67 | # Strip invalid architectures
68 | strip_invalid_archs() {
69 | binary="$1"
70 | # Get architectures for current file
71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
72 | stripped=""
73 | for arch in $archs; do
74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
75 | # Strip non-valid architectures in-place
76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
77 | stripped="$stripped $arch"
78 | fi
79 | done
80 | if [[ "$stripped" ]]; then
81 | echo "Stripped $binary of architectures:$stripped"
82 | fi
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | XCASSET_FILES=()
10 |
11 | case "${TARGETED_DEVICE_FAMILY}" in
12 | 1,2)
13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
14 | ;;
15 | 1)
16 | TARGET_DEVICE_ARGS="--target-device iphone"
17 | ;;
18 | 2)
19 | TARGET_DEVICE_ARGS="--target-device ipad"
20 | ;;
21 | *)
22 | TARGET_DEVICE_ARGS="--target-device mac"
23 | ;;
24 | esac
25 |
26 | install_resource()
27 | {
28 | if [[ "$1" = /* ]] ; then
29 | RESOURCE_PATH="$1"
30 | else
31 | RESOURCE_PATH="${PODS_ROOT}/$1"
32 | fi
33 | if [[ ! -e "$RESOURCE_PATH" ]] ; then
34 | cat << EOM
35 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
36 | EOM
37 | exit 1
38 | fi
39 | case $RESOURCE_PATH in
40 | *.storyboard)
41 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}"
42 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
43 | ;;
44 | *.xib)
45 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}"
46 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
47 | ;;
48 | *.framework)
49 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
50 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
51 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
52 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
53 | ;;
54 | *.xcdatamodel)
55 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\""
56 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
57 | ;;
58 | *.xcdatamodeld)
59 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\""
60 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
61 | ;;
62 | *.xcmappingmodel)
63 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\""
64 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
65 | ;;
66 | *.xcassets)
67 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
68 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
69 | ;;
70 | *)
71 | echo "$RESOURCE_PATH"
72 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
73 | ;;
74 | esac
75 | }
76 |
77 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
78 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
79 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
80 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
82 | fi
83 | rm -f "$RESOURCES_TO_COPY"
84 |
85 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
86 | then
87 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
88 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
89 | while read line; do
90 | if [[ $line != "${PODS_ROOT}*" ]]; then
91 | XCASSET_FILES+=("$line")
92 | fi
93 | done <<<"$OTHER_XCASSETS"
94 |
95 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
96 | fi
97 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject.debug.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/HomePageModule" "$PODS_CONFIGURATION_BUILD_DIR/MGJRouter" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/UserCenterModule"
5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/HomePageModule" -isystem "${PODS_ROOT}/Headers/Public/MGJRouter" -isystem "${PODS_ROOT}/Headers/Public/Masonry" -isystem "${PODS_ROOT}/Headers/Public/UserCenterModule"
6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"HomePageModule" -l"MGJRouter" -l"Masonry" -l"UserCenterModule" -framework "Foundation" -framework "UIKit"
7 | PODS_BUILD_DIR = $BUILD_DIR
8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_ROOT = ${SRCROOT}/Pods
10 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/Pods-MainProject/Pods-MainProject.release.xcconfig:
--------------------------------------------------------------------------------
1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/HomePageModule" "$PODS_CONFIGURATION_BUILD_DIR/MGJRouter" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/UserCenterModule"
5 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/HomePageModule" -isystem "${PODS_ROOT}/Headers/Public/MGJRouter" -isystem "${PODS_ROOT}/Headers/Public/Masonry" -isystem "${PODS_ROOT}/Headers/Public/UserCenterModule"
6 | OTHER_LDFLAGS = $(inherited) -ObjC -l"HomePageModule" -l"MGJRouter" -l"Masonry" -l"UserCenterModule" -framework "Foundation" -framework "UIKit"
7 | PODS_BUILD_DIR = $BUILD_DIR
8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
9 | PODS_ROOT = ${SRCROOT}/Pods
10 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/UserCenterModule/UserCenterModule-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_UserCenterModule : NSObject
3 | @end
4 | @implementation PodsDummy_UserCenterModule
5 | @end
6 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/UserCenterModule/UserCenterModule-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/MainProject/Pods/Target Support Files/UserCenterModule/UserCenterModule.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/UserCenterModule
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/UserCenterModule" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/HomePageModule" "${PODS_ROOT}/Headers/Public/MGJRouter" "${PODS_ROOT}/Headers/Public/Masonry" "${PODS_ROOT}/Headers/Public/UserCenterModule"
4 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MGJRouter"
5 | OTHER_LDFLAGS = -framework "UIKit"
6 | PODS_BUILD_DIR = $BUILD_DIR
7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_ROOT = ${SRCROOT}
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 刘小壮
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/README.md:
--------------------------------------------------------------------------------
1 | #UserModule
2 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/UserCenterModule/UserCenterModule/UserCenterModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // UserCenterModule.h
3 | // UserCenterModule
4 | //
5 | // Created by 刘小壮 on 2016/12/12.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UserCenterModule : NSObject
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/UserCenterModule/UserCenterModule/UserCenterModule.m:
--------------------------------------------------------------------------------
1 | //
2 | // UserCenterModule.m
3 | // UserCenterModule
4 | //
5 | // Created by 刘小壮 on 2016/12/12.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "UserCenterModule.h"
10 | #import
11 | #import "UserCenterViewController.h"
12 |
13 | @implementation UserCenterModule
14 |
15 | // 在load方法中自动注册,在主工程中不用写任何代码。
16 | + (void)load {
17 | [MGJRouter registerURLPattern:@"CTB://UserCenter/PushMainVC" toHandler:^(NSDictionary *routerParameters) {
18 | UINavigationController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
19 |
20 | UserCenterViewController *userCenterVC = [[UserCenterViewController alloc] init];
21 | [navigationVC pushViewController:userCenterVC animated:YES];
22 | }];
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/UserCenterModule/UserCenterModule/UserCenterViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // UserCenterModule
4 | //
5 | // Created by 刘小壮 on 2016/12/11.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UserCenterViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/MainProject/Pods/UserCenterModule/UserCenterModule/UserCenterModule/UserCenterViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // UserCenterModule
4 | //
5 | // Created by 刘小壮 on 2016/12/11.
6 | // Copyright © 2016年 刘小壮. All rights reserved.
7 | //
8 |
9 | #import "UserCenterViewController.h"
10 |
11 | @interface UserCenterViewController ()
12 |
13 | @end
14 |
15 | @implementation UserCenterViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | self.view.backgroundColor = [UIColor redColor];
21 | self.title = @"用户中心";
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > 这段时间好多同学说虽然提供了`Demo`,但还是不太清楚组件化架构的集成方式,包括怎么创建私有仓库和配置`Spec`之类的。正好这段时间不是太忙了,我在这里简单的写一下架构集成方面的东西。
2 |
3 | ***
4 |
5 | #### 组件化架构文章
6 |
7 | [组件化架构漫谈](https://www.jianshu.com/p/67a6004f6930)
8 |
9 |
10 |
11 | ### 创建私有仓库
12 |
13 | ##### 创建私有代码仓库
14 |
15 | 首先创建一个托管当前组件的私有代码仓库,然后将仓库`Clone`下来,把模块代码`Push`上去。例如下面的地址:
16 |
17 | https://git.coding.net/LiuXiaoZhuang/HomePageModule.git
18 |
19 | 这样就完成一个雏形了,可以通过这个代码仓库进行组件的代码管理了,这一块和平时的代码版本控制操作一样,所以就不详细讲了。
20 |
21 | ##### 创建私有Spec仓库
22 |
23 | 现在要创建私有的`Spec`仓库了。这时候你肯定有疑问了,不是已经有私有仓库了吗,这是干啥的?
24 |
25 | 很多人都在这块犯错了,所以这里要着重讲一下。就像`CocoaPods`的开源仓库一样,平时用来开发的代码和发布给别人使用的代码,是不在同一个仓库的。
26 |
27 | 例如`AFNetworking`,代码仓库是在[AFNetworking代码仓库](https://github.com/AFNetworking/AFNetworking.git)这里,而`AFNetworking`提供给其他人使用的时候,需要先提交到`CocoaPods`的`Spec`仓库,然后我们执行`pod install`都是从`Spec`仓库拉去下来的代码。这么说大家理解了吧,不理解就去我博客里留言吧。
28 |
29 | 例如我们创建的`Spec`仓库是下面的地址,最后提供给其他人的代码都要被提交到这里。创建`Spec`代码仓库和平时创建一样,只是这里暂时先为空,也不需要进行`Clone`操作。
30 |
31 | https://git.coding.net/LiuXiaoZhuang/HomePageModuleSpec.git
32 |
33 | ### 搭建环境
34 |
35 | ##### 创建.podspec文件
36 |
37 | 找到私有仓库`HomePageModule`所在的目录,在这个目录下通过下面命令,创建一个新的`.podspec`文件,在这个文件中来进行私有仓库的一些配置工作。
38 |
39 | ```
40 | pod spec create HomePageModule
41 | ```
42 |
43 | 创建这个文件后,需要修改里面的一些东西,例如这里我用`HomePageModule`私有仓库做例子。这里面修改的东西,表示你的`Spec`私有仓库的一些特征,例如`name`、`source`、`version`之类的,在进行`pod search`操作时候的显示结果,也是由这个文件决定的。
44 |
45 | 下面`source_files`指定的是文件路径,也就是最终导入到项目中的文件。下面的`exclude_files`指定的是不需要的文件路径,这些文件即便在`source_files`中,也不会被包含在`Pods`仓库中。
46 |
47 | 需要注意的是,下面的`source`设置为`HomePageModule`仓库而不是`Spec`仓库,这一步很多人都在这里犯错。另外,`podspec`文件中可能会有一些`Example`的字段,这些字段应该都进行修改,否则执行`pod`命令会报错。
48 |
49 | Pod::Spec.new do |s|
50 | s.name = "HomePageModule"
51 | s.version = "1.0"
52 | s.summary = "description of HomePageModule"
53 | s.description = <<-DESC
54 | "this is HomePageModule content description."
55 | DESC
56 | s.homepage = "https://coding.net/u/LiuXiaoZhuang/p/HomePageModule/git"
57 | s.license = "MIT"
58 | s.author = { "LiuXiaoZhuang" => "2046703959@qq.com" }
59 | s.source = { :git => "https://git.coding.net/LiuXiaoZhuang/HomePageModule.git", :tag => "#{s.version}" }
60 | s.exclude_files = "HomePageModule/HomePageModule/AppDelegate.{h,m}", "HomePageModule/HomePageModule/main.m"
61 | s.source_files = "HomePageModule/HomePageModule/*.{h,m}"
62 | s.frameworks = 'UIKit'
63 | s.platform = :ios
64 | end
65 |
66 | ### 开发过程
67 |
68 | ##### 验证podspec文件
69 |
70 | 先用`pod`命令验证一下这个`.podspec`文件有没有问题。
71 |
72 | ```
73 | pod lib lint
74 | ```
75 |
76 | 如果没问题会提示
77 |
78 | ```
79 | HomePageModule passed validation.
80 | ```
81 |
82 | 如果没问题就将`HomePageModule`的代码提交到私有服务器上,连同生成的`.podspec`文件也要一块提交上去。
83 |
84 | ##### 关联podspec到Spec私有仓库
85 |
86 | 通过下面命令,添加远程`Spec`仓库到本地,相当于建立一个连接关系。(需要注意这里的地址是`Spec`的地址,不要写错)
87 |
88 | ```
89 | pod repo add HomePageModule https://git.coding.net/LiuXiaoZhuang/HomePageModuleSpec.git
90 | ```
91 |
92 | 添加完成后,用下面命令检查一下是否成功。
93 |
94 | ```
95 | pod repo lint
96 | ```
97 |
98 | ##### 提交代码到Spec私有仓库
99 |
100 | 如果上面命令没问题后,这就代表组件的私有仓库和其对应的`Spec`仓库,已经可以提交并向外提供代码了。这时候我们就可以进行代码开发,开发完成之后通过下面的命令,将代码提交或更新到`Spec`仓库。
101 |
102 | ```
103 | pod repo push HomePageModule HomePageModule.podspec
104 | ```
105 |
106 | 提交给`Spec`私有仓库的文件,可以通过`.podspec`文件的`s.source_files`字段进行过滤,符合过滤条件的文件就都会被提交到`Spec`仓库。例如上面我们将所有`.h`和`.m`文件都提交到`Spec`仓库,除了这些还可以设置`imageAssets`、`XIB`、`Bundle`等文件。
107 |
108 | ### 使用私有仓库代码
109 |
110 | 当`Spec`私有仓库中有可用的代码后,就可以通过`CocoaPods`命令来使用组件代码了。在`Podfile`文件中需要声明私有仓库地址,例如下面代码。
111 |
112 | source 'https://git.coding.net/LiuXiaoZhuang/HomePageModuleSpec.git'
113 |
114 | target 'MainProject' do
115 | # 第三方库
116 | pod 'Masonry'
117 | pod 'MGJRouter'
118 |
119 | # 私有仓库
120 | pod 'HomePageModule', '~> 1.1'
121 | end
122 | 在配置好这套环境后,之后的开发就只需要执行上面`pod repo push`的操作了。根据业务需求发布指定的组件版本,并将组件`push`到`Spec`私有仓库供其他人使用即可。
123 |
124 | 版本控制也非常简单,只需要在`Podfile`中指定某个私有仓库的版本号即可。
125 |
126 | ### Local Pods
127 |
128 | 私有仓库调试比较麻烦,不可能是每修改一些代码,就提交到远端仓库,再拉下来验证代码是否有效。所以,为了提升开发效率,可以通过`LocalPods`的方式进行调试。或者不想用远端仓库,也可以直接用`LocalPods`的方案进行本地组件化,但是并不推荐这种方案,因为不能进行物理隔离。
129 |
130 | 本地`LocalPods`仓库不需要单独创建,直接用之前的组件仓库。在`pods`中使用本地仓库时,需要指定对应路径。指定路径后,执行`pod install`即可集成本地仓库。为了方便指定本地路径,建议将组件仓库尽量放在一个文件夹下,例如叫做`LocalPods`。
131 |
132 | ```objective-c
133 | pod 'Login', :path => './LocalPods/Login/'
134 | ```
135 |
136 | 通过上面的命令集成本地仓库后,`Pods`会生成一个和远程文件夹同级的文件,叫做`Development Pods`,这个文件夹就是本地仓库所在的位置。
137 |
138 | 此时之前`Login`仓库的产物就被替换为本地`LocalPods`中`Login`代码的产物了,后面的修改都会影响这个产物。直到调试完成,将代码提交到组件仓库,将`path`路径删除重新执行`pod install`,产物就会被替换为组件仓库的产物。
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------