├── LightDemo.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcuserdata
│ └── user.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── LightDemo.xcworkspace
├── contents.xcworkspacedata
├── xcshareddata
│ └── IDEWorkspaceChecks.plist
└── xcuserdata
│ └── user.xcuserdatad
│ └── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
├── LightDemo
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Contents.json
│ ├── indicator.imageset
│ │ ├── Contents.json
│ │ └── xishe.png
│ ├── light.imageset
│ │ ├── Contents.json
│ │ └── light.png
│ ├── light_one.imageset
│ │ ├── Contents.json
│ │ └── light_one.png
│ ├── light_two.imageset
│ │ ├── Contents.json
│ │ └── light_two.png
│ └── paletteColor.imageset
│ │ ├── Contents.json
│ │ └── paletteColor.png
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Defines
│ ├── Define.h
│ └── PrefixHeader.pch
├── Extension
│ ├── UIColorHelper
│ │ ├── UIColor+ColorHelper.h
│ │ └── UIColor+ColorHelper.m
│ ├── UIImageHelper
│ │ ├── UIImage+Color.h
│ │ ├── UIImage+Color.m
│ │ ├── UIImage+Size.h
│ │ └── UIImage+Size.m
│ └── UIViewHelper
│ │ ├── UIView+Frame.h
│ │ └── UIView+Frame.m
├── Info.plist
├── LightScene
│ ├── ADColorPicker.h
│ ├── ADColorPicker.m
│ ├── ADLightSlider.h
│ ├── ADLightSlider.m
│ ├── ADLightSwitch.h
│ ├── ADLightSwitch.m
│ ├── ADLightView.h
│ ├── ADLightView.m
│ ├── ADShadowView.h
│ └── ADShadowView.m
├── LightViewController.h
├── LightViewController.m
└── main.m
├── Podfile
├── Podfile.lock
├── Pods
├── Headers
│ ├── Private
│ │ ├── MJExtension
│ │ │ ├── MJExtension.h
│ │ │ ├── MJExtensionConst.h
│ │ │ ├── MJFoundation.h
│ │ │ ├── MJProperty.h
│ │ │ ├── MJPropertyKey.h
│ │ │ ├── MJPropertyType.h
│ │ │ ├── NSObject+MJClass.h
│ │ │ ├── NSObject+MJCoding.h
│ │ │ ├── NSObject+MJKeyValue.h
│ │ │ ├── NSObject+MJProperty.h
│ │ │ └── NSString+MJExtension.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
│ └── Public
│ │ ├── MJExtension
│ │ ├── MJExtension.h
│ │ ├── MJExtensionConst.h
│ │ ├── MJFoundation.h
│ │ ├── MJProperty.h
│ │ ├── MJPropertyKey.h
│ │ ├── MJPropertyType.h
│ │ ├── NSObject+MJClass.h
│ │ ├── NSObject+MJCoding.h
│ │ ├── NSObject+MJKeyValue.h
│ │ ├── NSObject+MJProperty.h
│ │ └── NSString+MJExtension.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
├── MJExtension
│ ├── LICENSE
│ ├── MJExtension
│ │ ├── MJExtension.h
│ │ ├── MJExtensionConst.h
│ │ ├── MJExtensionConst.m
│ │ ├── MJFoundation.h
│ │ ├── MJFoundation.m
│ │ ├── MJProperty.h
│ │ ├── MJProperty.m
│ │ ├── MJPropertyKey.h
│ │ ├── MJPropertyKey.m
│ │ ├── MJPropertyType.h
│ │ ├── MJPropertyType.m
│ │ ├── NSObject+MJClass.h
│ │ ├── NSObject+MJClass.m
│ │ ├── NSObject+MJCoding.h
│ │ ├── NSObject+MJCoding.m
│ │ ├── NSObject+MJKeyValue.h
│ │ ├── NSObject+MJKeyValue.m
│ │ ├── NSObject+MJProperty.h
│ │ ├── NSObject+MJProperty.m
│ │ ├── NSString+MJExtension.h
│ │ └── NSString+MJExtension.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
│ └── xcuserdata
│ │ └── user.xcuserdatad
│ │ └── xcschemes
│ │ ├── MJExtension.xcscheme
│ │ ├── Masonry.xcscheme
│ │ ├── Pods-LightDemo.xcscheme
│ │ └── xcschememanagement.plist
└── Target Support Files
│ ├── MJExtension
│ ├── MJExtension-dummy.m
│ ├── MJExtension-prefix.pch
│ └── MJExtension.xcconfig
│ ├── Masonry
│ ├── Masonry-dummy.m
│ ├── Masonry-prefix.pch
│ └── Masonry.xcconfig
│ └── Pods-LightDemo
│ ├── Pods-LightDemo-acknowledgements.markdown
│ ├── Pods-LightDemo-acknowledgements.plist
│ ├── Pods-LightDemo-dummy.m
│ ├── Pods-LightDemo-frameworks.sh
│ ├── Pods-LightDemo-resources.sh
│ ├── Pods-LightDemo.debug.xcconfig
│ └── Pods-LightDemo.release.xcconfig
├── README.md
└── light.gif
/LightDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LightDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LightDemo.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | LightDemo.xcscheme
8 |
9 | orderHint
10 | 3
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LightDemo.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LightDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LightDemo.xcworkspace/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/LightDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. 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 |
--------------------------------------------------------------------------------
/LightDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "LightViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 |
22 | // self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
23 | // self.window.backgroundColor = [UIColor whiteColor];
24 | // [self.window makeKeyAndVisible];
25 | // UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:[[LightViewController alloc] init]];
26 | // self.window.rootViewController = navi;
27 |
28 | return YES;
29 | }
30 |
31 |
32 | - (void)applicationWillResignActive:(UIApplication *)application {
33 | // 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.
34 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
35 | }
36 |
37 |
38 | - (void)applicationDidEnterBackground:(UIApplication *)application {
39 | // 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.
40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
41 | }
42 |
43 |
44 | - (void)applicationWillEnterForeground:(UIApplication *)application {
45 | // 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.
46 | }
47 |
48 |
49 | - (void)applicationDidBecomeActive:(UIApplication *)application {
50 | // 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.
51 | }
52 |
53 |
54 | - (void)applicationWillTerminate:(UIApplication *)application {
55 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
56 | }
57 |
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/indicator.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "xishe.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/indicator.imageset/xishe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/LightDemo/Assets.xcassets/indicator.imageset/xishe.png
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "light.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light.imageset/light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/LightDemo/Assets.xcassets/light.imageset/light.png
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light_one.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "light_one.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light_one.imageset/light_one.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/LightDemo/Assets.xcassets/light_one.imageset/light_one.png
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light_two.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "light_two.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/light_two.imageset/light_two.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/LightDemo/Assets.xcassets/light_two.imageset/light_two.png
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/paletteColor.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "paletteColor.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/LightDemo/Assets.xcassets/paletteColor.imageset/paletteColor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/LightDemo/Assets.xcassets/paletteColor.imageset/paletteColor.png
--------------------------------------------------------------------------------
/LightDemo/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 |
--------------------------------------------------------------------------------
/LightDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/LightDemo/Defines/Define.h:
--------------------------------------------------------------------------------
1 | //
2 | // Define.h
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #ifndef Define_h
10 | #define Define_h
11 |
12 | // 在release版本中关闭NSLog打印
13 | #ifdef DEBUG
14 | #define NSLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
15 | #else
16 | #define NSLog(format, ...)
17 | #endif
18 |
19 | //屏幕宽高
20 | #define ScreenHeight [[UIScreen mainScreen] bounds].size.height
21 | #define ScreenWidth [[UIScreen mainScreen] bounds].size.width
22 | #define Width self.view.frame.size.width
23 | #define Height self.view.frame.size.height
24 |
25 | /**
26 | 比例以宽来计算
27 | 总共三种尺寸,320, 375, 414
28 | */
29 | #define Suit414Width 1.104
30 | #define Suit320Width 1.171875
31 |
32 | // 系统判定
33 | #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
34 | #define IS_IOS8 (IOS_VERSION >= 8.0 && IOS_VERSION < 9.0)
35 | #define IS_IOS9 (IOS_VERSION >= 9.0 && IOS_VERSION < 10.0)
36 | #define IS_IOS10 (IOS_VERSION >= 10.0 && IOS_VERSION < 11.0)
37 | #define IS_IOS11 (IOS_VERSION >= 11.0 && IOS_VERSION < 12.0)
38 | #define IS_IOS12 (IOS_VERSION >= 12.0)
39 |
40 | // 屏幕判定(最低5)
41 | #define IS_IPHONE4INCH (ScreenHeight == 568 ? YES : NO)//5,se
42 | #define IS_IPHONE47INCH (ScreenHeight == 667 ? YES : NO)//6, 7,8
43 | #define IS_IPHONE55INCH (ScreenHeight == 736 ? YES : NO)//6,7,8 plus
44 | #define IS_IPHONE58INCH (ScreenHeight == 812 ? YES : NO)//x, xs
45 | #define IS_IPHONE6INCH (ScreenHeight == 896 ? YES : NO)//xr, xs max
46 |
47 | //屏宽320
48 | #define IS_WIDTH320 (IS_IPHONE4INCH ? YES : NO)
49 | //屏宽375
50 | #define IS_WIDTH375 ((IS_IPHONE47INCH || IS_IPHONE58INCH) ? YES : NO)
51 | //屏宽414
52 | #define IS_WIDTH414 ((IS_IPHONE55INCH || IS_IPHONE6INCH) ? YES : NO)
53 |
54 | // naviBar, statusBar, tabBar
55 | #define IS_SPECIALHEIGHTBAR ((IS_IPHONE58INCH || IS_IPHONE6INCH) ? YES : NO)
56 | #define HEIGHT_STATUSBAR (IS_SPECIALHEIGHTBAR ? 44 : 20)
57 | #define HEIGHT_TABBAR (IS_SPECIALHEIGHTBAR ? 83 : 49)
58 | #define HEIGHT_NAVBAR (IS_SPECIALHEIGHTBAR ? 88 : 64)
59 |
60 | #endif /* Define_h */
61 |
--------------------------------------------------------------------------------
/LightDemo/Defines/PrefixHeader.pch:
--------------------------------------------------------------------------------
1 | //
2 | // PrefixHeader.pch
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #ifndef PrefixHeader_pch
10 | #define PrefixHeader_pch
11 |
12 | // Include any system framework and library headers here that should be included in all compilation units.
13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
14 |
15 | #import "Define.h"
16 | #import "MJExtension.h"
17 | #import "Masonry.h"
18 | #import "UIColor+ColorHelper.h"
19 |
20 |
21 | #endif /* PrefixHeader_pch */
22 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIColorHelper/UIColor+ColorHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+ColorHelper.h
3 | // BaseFramework
4 | //
5 | // Created by hztuen on 17/3/3.
6 | // Copyright © 2017年 Cesar. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (ColorHelper)
12 |
13 | //UIColor 转16进制字符串
14 | + (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha;
15 |
16 | //UIColor 转UIImage
17 | + (UIImage*) imageWithColor: (UIColor*) color;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIColorHelper/UIColor+ColorHelper.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+ColorHelper.m
3 | // BaseFramework
4 | //
5 | // Created by hztuen on 17/3/3.
6 | // Copyright © 2017年 Cesar. All rights reserved.
7 | //
8 |
9 | #import "UIColor+ColorHelper.h"
10 |
11 | @implementation UIColor (ColorHelper)
12 |
13 | + (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha {
14 | //删除字符串中的空格
15 | NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
16 | // String should be 6 or 8 characters
17 | if ([cString length] < 6)
18 | {
19 | return [UIColor clearColor];
20 | }
21 | //如果是0x开头的,那么截取字符串,字符串从索引为2的位置开始,一直到末尾
22 | if ([cString hasPrefix:@"0X"])
23 | {
24 | cString = [cString substringFromIndex:2];
25 | }
26 | //如果是#开头的,那么截取字符串,字符串从索引为1的位置开始,一直到末尾
27 | if ([cString hasPrefix:@"#"])
28 | {
29 | cString = [cString substringFromIndex:1];
30 | }
31 | if ([cString length] != 6)
32 | {
33 | return [UIColor clearColor];
34 | }
35 |
36 | // Separate into r, g, b substrings
37 | NSRange range;
38 | range.location = 0;
39 | range.length = 2;
40 | //r
41 | NSString *rString = [cString substringWithRange:range];
42 | //g
43 | range.location = 2;
44 | NSString *gString = [cString substringWithRange:range];
45 | //b
46 | range.location = 4;
47 | NSString *bString = [cString substringWithRange:range];
48 |
49 | // Scan values
50 | unsigned int r, g, b;
51 | [[NSScanner scannerWithString:rString] scanHexInt:&r];
52 | [[NSScanner scannerWithString:gString] scanHexInt:&g];
53 | [[NSScanner scannerWithString:bString] scanHexInt:&b];
54 | return [UIColor colorWithRed:((float)r / 255.0f) green:((float)g / 255.0f) blue:((float)b / 255.0f) alpha:alpha];
55 | }
56 |
57 | //UIColor 转UIImage
58 | + (UIImage*) imageWithColor: (UIColor*) color
59 | {
60 | CGRect rect=CGRectMake(0,0, 1, 1);
61 | UIGraphicsBeginImageContext(rect.size);
62 | CGContextRef context = UIGraphicsGetCurrentContext();
63 | CGContextSetFillColorWithColor(context, [color CGColor]);
64 | CGContextFillRect(context, rect);
65 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
66 | UIGraphicsEndImageContext();
67 | return theImage;
68 | }
69 |
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIImageHelper/UIImage+Color.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Color.h
3 | // WhichBank
4 | //
5 | // Created by libokun on 15/9/6.
6 | // Copyright (c) 2015年 lettai. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (Color)
12 |
13 | + (UIImage *)imageWithColor:(UIColor *)color;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIImageHelper/UIImage+Color.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Color.m
3 | // WhichBank
4 | //
5 | // Created by libokun on 15/9/6.
6 | // Copyright (c) 2015年 lettai. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Color.h"
10 |
11 | @implementation UIImage (Color)
12 |
13 | + (UIImage *)imageWithColor:(UIColor *)color {
14 | CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
15 | UIGraphicsBeginImageContext(rect.size);
16 | CGContextRef context = UIGraphicsGetCurrentContext();
17 | CGContextSetFillColorWithColor(context, [color CGColor]);
18 | CGContextFillRect(context, rect);
19 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
20 | UIGraphicsEndImageContext();
21 |
22 | return theImage;
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIImageHelper/UIImage+Size.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Size.h
3 | // HChat
4 | //
5 | // Created by 姜超 on Now
6 | // Copyright © 2017年 姜超. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (Size)
12 |
13 | - (UIImage *)scalingToSize:(CGSize)size;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIImageHelper/UIImage+Size.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+Size.m
3 | // HChat
4 | //
5 | // Created by 姜超 on Now
6 | // Copyright © 2017年 姜超. All rights reserved.
7 | //
8 |
9 | #import "UIImage+Size.h"
10 |
11 | @implementation UIImage (Size)
12 |
13 | - (UIImage *)scalingToSize:(CGSize)size {
14 | CGFloat scale = 0.0f;
15 | CGFloat x = 0.0f;
16 | CGFloat y = 0.0f;
17 | CGFloat width = size.width;
18 | CGFloat height = size.height;
19 | if (CGSizeEqualToSize(self.size, size) == NO) {
20 | CGFloat widthFactor = size.width / self.size.width;
21 | CGFloat heightFactor = size.height / self.size.height;
22 | scale = (widthFactor > heightFactor ? widthFactor : heightFactor);
23 | width = self.size.width * scale;
24 | height = self.size.height * scale;
25 | y = (size.height - height) * 0.5;
26 |
27 | x = (size.width - width) * 0.5;
28 |
29 | }
30 | // this is actually the interesting part:
31 | UIGraphicsBeginImageContext(size);
32 | [self drawInRect:CGRectMake(x, y, width, height)];
33 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
34 | UIGraphicsEndImageContext();
35 | if(newImage == nil) {
36 | NSLog(@"绘制指定大小的图片失败");
37 | return self;
38 | }
39 | return newImage ;
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIViewHelper/UIView+Frame.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+Frame.h
3 | // HChat
4 | //
5 | // Created by 姜超 on Now
6 | // Copyright © 2017年 姜超. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIView (Frame)
12 |
13 | @property (nonatomic, assign) CGFloat x;
14 | @property (nonatomic, assign) CGFloat y;
15 |
16 | @property (nonatomic, assign) CGPoint origin;
17 | @property (nonatomic, assign) CGSize size;
18 |
19 | @property (nonatomic) CGFloat centerX;
20 | @property (nonatomic) CGFloat centerY;
21 |
22 | @property (nonatomic) CGFloat top;
23 | @property (nonatomic) CGFloat bottom;
24 | @property (nonatomic) CGFloat right;
25 | @property (nonatomic) CGFloat left;
26 |
27 | @property (nonatomic) CGFloat width;
28 | @property (nonatomic) CGFloat height;
29 |
30 | - (UIView *)subViewOfClassName:(NSString*)className;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/LightDemo/Extension/UIViewHelper/UIView+Frame.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+Frame.m
3 | // HChat
4 | //
5 | // Created by 姜超 on Now
6 | // Copyright © 2017年 姜超. All rights reserved.
7 | //
8 |
9 | #import "UIView+Frame.h"
10 |
11 | @implementation UIView (Frame)
12 |
13 | - (CGFloat)x
14 | {
15 | return self.frame.origin.x;
16 | }
17 |
18 | - (void)setX:(CGFloat)x
19 | {
20 | CGRect frame = self.frame;
21 | frame.origin.x = x;
22 | self.frame = frame;
23 | }
24 |
25 | - (CGFloat)y
26 | {
27 | return self.frame.origin.y;
28 | }
29 |
30 | - (void)setY:(CGFloat)y
31 | {
32 | CGRect frame = self.frame;
33 | frame.origin.y = y;
34 | self.frame = frame;
35 | }
36 |
37 | #pragma mark - Shortcuts for the coords
38 | - (CGFloat)top
39 | {
40 | return self.frame.origin.y;
41 | }
42 |
43 | - (void)setTop:(CGFloat)y
44 | {
45 | CGRect frame = self.frame;
46 | frame.origin.y = y;
47 | self.frame = frame;
48 | }
49 |
50 | - (CGFloat)right
51 | {
52 | return self.frame.origin.x + self.frame.size.width;
53 | }
54 |
55 | - (void)setRight:(CGFloat)right
56 | {
57 | CGRect frame = self.frame;
58 | frame.origin.x = right - self.frame.size.width;
59 | self.frame = frame;
60 | }
61 |
62 | - (CGFloat)bottom
63 | {
64 | return self.frame.origin.y + self.frame.size.height;
65 | }
66 |
67 | - (void)setBottom:(CGFloat)bottom
68 | {
69 | CGRect frame = self.frame;
70 | frame.origin.y = bottom - self.frame.size.height;
71 | self.frame = frame;
72 | }
73 |
74 | - (CGFloat)left
75 | {
76 | return self.frame.origin.x;
77 | }
78 |
79 | - (void)setLeft:(CGFloat)x
80 | {
81 | CGRect frame = self.frame;
82 | frame.origin.x = x;
83 | self.frame = frame;
84 | }
85 |
86 | - (CGFloat)width
87 | {
88 | return self.frame.size.width;
89 | }
90 |
91 | - (void)setWidth:(CGFloat)width
92 | {
93 | CGRect frame = self.frame;
94 | frame.size.width = width;
95 | self.frame = frame;
96 | }
97 |
98 | - (CGFloat)height
99 | {
100 | return self.frame.size.height;
101 | }
102 |
103 | - (void)setHeight:(CGFloat)height
104 | {
105 | CGRect frame = self.frame;
106 | frame.size.height = height;
107 | self.frame = frame;
108 | }
109 |
110 | #pragma mark - Shortcuts for frame properties
111 | - (CGPoint)origin {
112 | return self.frame.origin;
113 | }
114 |
115 | - (void)setOrigin:(CGPoint)origin {
116 | CGRect frame = self.frame;
117 | frame.origin = origin;
118 | self.frame = frame;
119 | }
120 |
121 | - (CGSize)size {
122 | return self.frame.size;
123 | }
124 |
125 | - (void)setSize:(CGSize)size {
126 | CGRect frame = self.frame;
127 | frame.size = size;
128 | self.frame = frame;
129 | }
130 |
131 | #pragma mark - Shortcuts for positions
132 | - (CGFloat)centerX {
133 | return self.center.x;
134 | }
135 |
136 | - (void)setCenterX:(CGFloat)centerX {
137 | self.center = CGPointMake(centerX, self.center.y);
138 | }
139 |
140 | - (CGFloat)centerY {
141 | return self.center.y;
142 | }
143 |
144 | - (void)setCenterY:(CGFloat)centerY {
145 | self.center = CGPointMake(self.center.x, centerY);
146 | }
147 |
148 | - (UIView *)subViewOfClassName:(NSString*)className {
149 | for (UIView* subView in self.subviews) {
150 | if ([NSStringFromClass(subView.class) isEqualToString:className]) {
151 | return subView;
152 | }
153 |
154 | UIView* resultFound = [subView subViewOfClassName:className];
155 | if (resultFound) {
156 | return resultFound;
157 | }
158 | }
159 | return nil;
160 | }
161 |
162 | @end
163 |
--------------------------------------------------------------------------------
/LightDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UIStatusBarStyle
32 | UIStatusBarStyleLightContent
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADColorPicker.h:
--------------------------------------------------------------------------------
1 | //
2 | // ADColorPicker.h
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/16.
6 | // Copyright © 2018 adu. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol ADColorPickerDelegate
12 |
13 | - (void)getCurrentColor:(UIColor *)color;
14 |
15 | @end
16 |
17 | @interface ADColorPicker : UIView
18 |
19 | @property (nonatomic, weak) id delegate;
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADColorPicker.m:
--------------------------------------------------------------------------------
1 | //
2 | // ADColorPicker.m
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/16.
6 | // Copyright © 2018 adu. All rights reserved.
7 | //
8 |
9 | #import "ADColorPicker.h"
10 |
11 | #define WIDTH self.bounds.size.width
12 | #define HEIGHT self.bounds.size.height
13 | #define CENTER CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.5)
14 |
15 | @interface ADColorPicker ()
16 |
17 | @property (nonatomic, strong) UIImageView *centerImage;//中间的图片
18 |
19 | @end
20 |
21 | @implementation ADColorPicker
22 |
23 | - (instancetype)initWithFrame:(CGRect)frame {
24 | if (self = [super initWithFrame:frame]) {
25 | [self initConfig];
26 | [self buildColorPicker];
27 | }
28 | return self;
29 | }
30 |
31 | - (void)initConfig {
32 | self.backgroundColor = [UIColor clearColor];
33 | }
34 |
35 | - (void)buildColorPicker {
36 | UIImageView *palette = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"paletteColor"]];
37 | [self addSubview:palette];
38 | [palette mas_makeConstraints:^(MASConstraintMaker *make) {
39 | make.centerX.equalTo(self.mas_centerX);
40 | make.centerY.equalTo(self.mas_centerY);
41 | make.width.height.mas_equalTo((self.bounds.size.width > self.bounds.size.height) ? (self.bounds.size.height - [self Suit:20]) : (self.bounds.size.width - [self Suit:20]));
42 | }];
43 |
44 | self.centerImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"indicator"]];
45 | self.centerImage.contentMode = UIViewContentModeScaleAspectFill;
46 | [self addSubview:self.centerImage];
47 | [self.centerImage mas_makeConstraints:^(MASConstraintMaker *make) {
48 | make.centerX.equalTo(self.mas_centerX);
49 | make.centerY.equalTo(self.mas_centerY);
50 | make.width.height.mas_equalTo([self Suit:30]);
51 | }];
52 | }
53 |
54 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
55 | UITouch *touch = [touches anyObject];
56 | CGPoint currentPoint = [touch locationInView:self];
57 |
58 | CGFloat chassRadius = (HEIGHT - 20)*0.5 - [self Suit:15/2];
59 | CGFloat absDistanceX = fabs(currentPoint.x - CENTER.x);
60 | CGFloat absDistanceY = fabs(currentPoint.y - CENTER.y);
61 | CGFloat currentTopointRadius = sqrtf(absDistanceX * absDistanceX + absDistanceY *absDistanceY);
62 |
63 | if(currentTopointRadius < chassRadius) {//实在色盘上面
64 | self.centerImage.center = currentPoint;
65 | UIColor *color = [self getPixelColorAtLocation:currentPoint];
66 | if(self.delegate && [self.delegate respondsToSelector:@selector(getCurrentColor:)]) {
67 |
68 | [self.delegate getCurrentColor:color];
69 | }
70 | }
71 | }
72 |
73 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
74 |
75 | UITouch *touch = [touches anyObject];
76 | CGPoint currentPoint = [touch locationInView:self];
77 |
78 | CGFloat chassRadius = (HEIGHT - 20)*0.5 - [self Suit:15/2];
79 | CGFloat absDistanceX = fabs(currentPoint.x - CENTER.x);
80 | CGFloat absDistanceY = fabs(currentPoint.y - CENTER.y);
81 | CGFloat currentTopointRadius = sqrtf(absDistanceX * absDistanceX + absDistanceY *absDistanceY);
82 |
83 | if (currentTopointRadius < chassRadius) {
84 | //取色
85 | self.centerImage.center = currentPoint;
86 | UIColor *color = [self getPixelColorAtLocation:currentPoint];
87 | if(self.delegate && [self.delegate respondsToSelector:@selector(getCurrentColor:)]) {
88 | [self.delegate getCurrentColor:color];
89 | }
90 | }
91 |
92 | }
93 |
94 | - (UIColor*)getPixelColorAtLocation:(CGPoint)point {
95 | UIColor *color = nil;
96 |
97 | UIGraphicsBeginImageContext(self.bounds.size);
98 | [self.layer renderInContext:UIGraphicsGetCurrentContext()];
99 | UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
100 | CGImageRef inImage = viewImage.CGImage;
101 |
102 | CGContextRef cgctx = [self createARGBBitmapContextFromImage:inImage];
103 | if (cgctx == NULL) {
104 | return nil;
105 | }
106 |
107 | size_t w = self.bounds.size.width;
108 | size_t h = self.bounds.size.height;
109 |
110 | CGRect rect = {{0,0},{w,h}};
111 |
112 | CGContextDrawImage(cgctx, rect, inImage);
113 |
114 | unsigned char *data = CGBitmapContextGetData (cgctx);
115 | if (data != NULL) {
116 | int offset = 4*((w*round(point.y))+round(point.x));
117 | int alpha = data[offset];
118 | int red = data[offset+1];
119 | int green = data[offset+2];
120 | int blue = data[offset+3];
121 | color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)];
122 | }
123 | CGContextRelease(cgctx);
124 | if (data) { free(data); }
125 |
126 | return color;
127 | }
128 |
129 | - (CGContextRef)createARGBBitmapContextFromImage:(CGImageRef)inImage {
130 | CGContextRef context = NULL;
131 | CGColorSpaceRef colorSpace;
132 | void * bitmapData;
133 | int bitmapByteCount;
134 | int bitmapBytesPerRow;
135 |
136 | size_t pixelsWide = self.bounds.size.width;
137 | size_t pixelsHigh = self.bounds.size.height;
138 |
139 | bitmapBytesPerRow = (pixelsWide * 4);
140 | bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);
141 |
142 | colorSpace = CGColorSpaceCreateDeviceRGB();
143 |
144 | if (colorSpace == NULL) {
145 | fprintf(stderr, "Error allocating color space\n");
146 | return NULL;
147 | }
148 |
149 | bitmapData = malloc( bitmapByteCount );
150 | if (bitmapData == NULL) {
151 | fprintf (stderr, "Memory not allocated!");
152 | CGColorSpaceRelease( colorSpace );
153 | return NULL;
154 | }
155 |
156 | context = CGBitmapContextCreate (bitmapData,
157 | pixelsWide,
158 | pixelsHigh,
159 | 8,
160 | bitmapBytesPerRow,
161 | colorSpace,
162 | kCGImageAlphaPremultipliedFirst);
163 | if (context == NULL) {
164 | free (bitmapData);
165 | fprintf (stderr, "Context not created!");
166 | }
167 |
168 | CGColorSpaceRelease( colorSpace );
169 |
170 | return context;
171 | }
172 |
173 | /**
174 | 适配 给定375屏尺寸,适配320和414屏尺寸
175 | */
176 | - (float)Suit:(float)MySuit {
177 | IS_WIDTH320 ? (MySuit = MySuit / Suit320Width) : (IS_WIDTH414 ? (MySuit = MySuit * Suit414Width) : MySuit);
178 | return MySuit;
179 | }
180 |
181 | /**
182 | 适配 给定375屏字号,适配320和414屏字号
183 | */
184 | - (float)SuitFont:(float)font {
185 | IS_WIDTH320 ? (font = font - 1) : (IS_WIDTH414 ? (font = font + 1) : font);
186 | return font;
187 | }
188 |
189 |
190 | /*
191 | // Only override drawRect: if you perform custom drawing.
192 | // An empty implementation adversely affects performance during animation.
193 | - (void)drawRect:(CGRect)rect {
194 | // Drawing code
195 | }
196 | */
197 |
198 | @end
199 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightSlider.h:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightSlider.h
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @protocol ADSliderDelegate
14 |
15 | - (void)getCurrentSliderValue:(CGFloat)value;
16 |
17 | @end
18 |
19 |
20 | @interface ADLightSlider : UIView
21 |
22 | @property (nonatomic, assign) CGFloat value;
23 | @property (nonatomic, strong) UIView *slideView;
24 | @property (nonatomic, strong) UIColor *slideColor;
25 |
26 | @property (nonatomic, weak) id delegate;
27 |
28 | @end
29 |
30 | NS_ASSUME_NONNULL_END
31 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightSlider.m:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightSlider.m
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import "ADLightSlider.h"
10 |
11 | @interface ADLightSlider ()
12 |
13 | @property (nonatomic, strong) UIView *bgView;
14 | @property (nonatomic, strong) CALayer *shadowLayer;
15 | @property (nonatomic, assign) CGRect orignFrame;
16 |
17 | @end
18 |
19 | @implementation ADLightSlider
20 |
21 | - (instancetype)initWithFrame:(CGRect)frame {
22 | if (self = [super initWithFrame:frame]) {
23 | [self initConfig];
24 | [self buildSliderview];
25 | }
26 | return self;
27 | }
28 |
29 | - (void)setValue:(CGFloat)value {
30 | _value = value;
31 | [self refreshUI];
32 | self.slideView.alpha = value;
33 | }
34 |
35 | - (void)setSlideColor:(UIColor *)slideColor {
36 | _slideColor = slideColor;
37 | self.slideView.backgroundColor = self.slideColor;
38 | self.shadowLayer.shadowColor = self.slideColor.CGColor;
39 | }
40 |
41 | - (void)refreshUI {
42 | self.slideView.frame = CGRectMake(0, self.bgView.frame.size.height - self.bgView.frame.size.height * self.value, self.bgView.frame.size.width, self.bgView.frame.size.height * self.value);
43 | }
44 |
45 | - (void)initConfig {
46 | self.orignFrame = self.frame;
47 | self.value = 0.6;
48 | }
49 |
50 |
51 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
52 | //放大效果
53 | [UIView animateWithDuration:0.6 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseInOut animations:^{
54 | self.transform = CGAffineTransformMakeScale(1.1f, 1.1f);
55 | } completion:nil];
56 | }
57 |
58 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
59 | //缩小效果
60 | [UIView animateWithDuration:0.6 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseInOut animations:^{
61 | self.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
62 | } completion:nil];
63 | }
64 |
65 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
66 | NSSet *allTouches = [event allTouches];
67 | UITouch *touch = [allTouches anyObject];
68 | CGPoint point = [touch locationInView:self.bgView];
69 | int y = point.y;
70 | if (y <= 0) {
71 | y = 0;
72 | }
73 | if (y >= self.bgView.frame.size.height) {
74 | y = self.bgView.frame.size.height;
75 | }
76 | self.value = (self.bgView.frame.size.height - y) / self.bgView.frame.size.height;
77 | if(self.delegate && [self.delegate respondsToSelector:@selector(getCurrentSliderValue:)]) {
78 | [self.delegate getCurrentSliderValue:self.value];
79 | }
80 | }
81 |
82 |
83 | - (void)buildSliderview {
84 | self.bgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, self.orignFrame.size.width - 10, self.orignFrame.size.height - 10)];
85 | self.bgView.backgroundColor = [UIColor lightGrayColor];
86 | self.bgView.layer.cornerRadius = 12;
87 | self.bgView.clipsToBounds = YES;
88 | [self addSubview:self.bgView];
89 |
90 | self.shadowLayer = [CALayer layer];
91 | self.shadowLayer.shadowOpacity = 0.3;
92 | self.shadowLayer.shadowRadius = 12;
93 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:1.0];
94 | self.shadowLayer.shadowPath = path.CGPath;
95 | [self.layer addSublayer:self.shadowLayer];
96 |
97 | self.slideView = [[UIView alloc] initWithFrame:CGRectMake(0, self.bgView.frame.size.height - self.bgView.frame.size.height * self.value, self.bgView.frame.size.width, self.bgView.frame.size.height * self.value)];
98 | self.slideColor = [UIColor colorWithHexString:@"ffffff" alpha:1.0];
99 | [self.bgView addSubview:self.slideView];
100 | }
101 |
102 | /*
103 | // Only override drawRect: if you perform custom drawing.
104 | // An empty implementation adversely affects performance during animation.
105 | - (void)drawRect:(CGRect)rect {
106 | // Drawing code
107 | }
108 | */
109 |
110 | @end
111 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightSwitch.h:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightSwitch.h
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | typedef void(^ADSwitchDidSelectedBlock)(BOOL isOn);
14 |
15 | typedef enum {
16 | SwitchVertical = 0,
17 | SwitchHorizontal
18 | } SwitchOrientation;
19 |
20 | @interface ADLightSwitch : UIView
21 |
22 | @property (nonatomic, strong) UIColor *onColor; //开的颜色
23 | @property (nonatomic, strong) UIColor *offColor; //关的颜色
24 | @property (nonatomic, strong) UIColor *headColor; //圆圈颜色
25 | @property (nonatomic, assign) BOOL isOn;
26 |
27 | - (void)setADSwitchDidSelectedBlock:(ADSwitchDidSelectedBlock)block;
28 | - (instancetype)initWithFrame:(CGRect)frame WithOrientation:(SwitchOrientation)orientation;
29 |
30 | @end
31 |
32 | NS_ASSUME_NONNULL_END
33 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightSwitch.m:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightSwitch.m
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import "ADLightSwitch.h"
10 |
11 | @interface ADLightSwitch () {
12 | CGFloat _moveDistance; //移动距离
13 | BOOL isAnimating; //是否在动画中
14 | BOOL _isSwitched; //开关操作是否已经执行过
15 | ADSwitchDidSelectedBlock _adSwitchDidSelectedBlock;
16 | }
17 |
18 | //@property (nonatomic, strong) UIView *line;
19 | @property (nonatomic, assign) SwitchOrientation orientation; //方向
20 | @property (nonatomic, strong) UISwipeGestureRecognizer *swipe;
21 | @property (nonatomic, strong) CAShapeLayer *headLayer;
22 |
23 | @end
24 |
25 | const CGFloat kAnimationDuration = 0.4f;
26 |
27 | @implementation ADLightSwitch
28 |
29 | #pragma mark set method
30 | - (void)setOnColor:(UIColor *)onColor {
31 | _onColor = onColor;
32 | if (_isOn) {
33 | self.backgroundColor = _onColor;
34 | }
35 | }
36 |
37 | - (void)setOffColor:(UIColor *)offColor {
38 | _offColor = offColor;
39 | if (!_isOn) {
40 | self.backgroundColor = _offColor;
41 | }
42 | }
43 |
44 | - (void)setHeadColor:(UIColor *)headColor {
45 | _headColor = headColor;
46 | self.headLayer.fillColor = _headColor.CGColor;
47 | }
48 |
49 | - (void)setIsOn:(BOOL)isOn {
50 | _isOn = isOn;
51 | self.backgroundColor = _isOn?_onColor:_offColor;
52 | if (_orientation == SwitchVertical) {
53 | _headLayer.position = CGPointMake(_headLayer.position.x, _isOn ? _headLayer.position.y + _moveDistance : (_isSwitched ? _headLayer.position.y - _moveDistance : _headLayer.position.y));
54 | self.swipe.direction = self.isOn ? UISwipeGestureRecognizerDirectionUp : UISwipeGestureRecognizerDirectionDown;
55 | } else {
56 | _headLayer.position = CGPointMake(_isOn ? _headLayer.position.x + _moveDistance : (_isSwitched ? _headLayer.position.x - _moveDistance : _headLayer.position.x), _headLayer.position.y);
57 | self.swipe.direction = self.isOn ? UISwipeGestureRecognizerDirectionLeft : UISwipeGestureRecognizerDirectionRight;
58 | }
59 | }
60 |
61 | - (void)setOrientation:(SwitchOrientation)orientation {
62 | _orientation = orientation;
63 | if (_orientation == SwitchVertical) {
64 | //垂直
65 | _moveDistance = self.frame.size.height - self.frame.size.width;
66 | self.layer.cornerRadius = self.frame.size.width/2;
67 | } else {
68 | //水平
69 | _moveDistance = self.frame.size.width - self.frame.size.height;
70 | self.layer.cornerRadius = self.frame.size.height/2;
71 | }
72 | }
73 |
74 | - (CALayer *)headLayer {
75 | if (!_headLayer) {
76 | _headLayer = [CAShapeLayer layer];
77 | if (_orientation == SwitchVertical) {
78 | _headLayer.frame = CGRectMake(self.frame.size.width * 0.2, self.frame.size.width * 0.2, self.frame.size.width * 0.6, self.frame.size.width * 0.6);
79 | } else {
80 | _headLayer.frame = CGRectMake(self.frame.size.height * 0.2, self.frame.size.height * 0.2, self.frame.size.height * 0.6, self.frame.size.height * 0.6);
81 | }
82 | UIBezierPath * path = [UIBezierPath bezierPathWithOvalInRect:_headLayer.bounds];
83 | _headLayer.shadowOffset = CGSizeMake(0, 0);
84 | _headLayer.shadowColor = [UIColor blackColor].CGColor;
85 | _headLayer.shadowOpacity = 0.3;
86 | _headLayer.path = path.CGPath;
87 |
88 | [self.layer addSublayer:_headLayer];
89 | }
90 | return _headLayer;
91 | }
92 |
93 | - (void)setADSwitchDidSelectedBlock:(ADSwitchDidSelectedBlock)block {
94 | _adSwitchDidSelectedBlock = block;
95 | }
96 |
97 | #pragma mark
98 | - (instancetype)initWithFrame:(CGRect)frame WithOrientation:(SwitchOrientation)orientation {
99 | if(self = [super initWithFrame:frame]) {
100 | [self setOrientation:orientation];
101 | [self initADSwitch];
102 | [self addGestures];
103 |
104 | }
105 | return self;
106 | }
107 |
108 | - (instancetype)initWithFrame:(CGRect)frame {
109 | if (self = [super initWithFrame:frame]) {
110 | if (self.frame.size.width > self.frame.size.height) {
111 | [self setOrientation:SwitchHorizontal];
112 | } else {
113 | [self setOrientation:SwitchVertical];
114 | }
115 | [self initADSwitch];
116 | [self addGestures];
117 | }
118 | return self;
119 | }
120 |
121 | - (void)addGestures {
122 | //点击
123 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(switchAnimate)];
124 | [self addGestureRecognizer:tap];
125 |
126 | //滑动
127 | self.swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(switchAnimate)];
128 | if (_orientation == SwitchVertical) {
129 | self.swipe.direction = self.isOn ? UISwipeGestureRecognizerDirectionUp : UISwipeGestureRecognizerDirectionDown;
130 | } else {
131 | self.swipe.direction = self.isOn ? UISwipeGestureRecognizerDirectionLeft : UISwipeGestureRecognizerDirectionRight;
132 | }
133 | [self addGestureRecognizer:self.swipe];
134 | }
135 |
136 | - (void)initADSwitch {
137 | isAnimating = NO;
138 | _isOn = NO;
139 | _isSwitched = NO;
140 |
141 | self.onColor = [UIColor colorWithHexString:@"ffffff" alpha:1.0];
142 | self.offColor = [UIColor colorWithHexString:@"dcdcdc" alpha:1.0];
143 | self.headColor = [UIColor colorWithHexString:@"F8F8FF" alpha:1.0];
144 | }
145 |
146 | #pragma mark Tap GestureRecognizer
147 | - (void)switchAnimate {
148 | if (isAnimating) {
149 | return;
150 | }
151 |
152 | isAnimating = YES;
153 |
154 | CABasicAnimation *headLayerPositionAnimation;
155 | if (self.orientation == SwitchVertical) {
156 | headLayerPositionAnimation = [self animationForHeadLayerWithBeginPosition:self.headLayer.position endPosition:CGPointMake(self.headLayer.position.x, _isOn?self.headLayer.position.y - _moveDistance:self.headLayer.position.y + _moveDistance)];
157 | } else {
158 | headLayerPositionAnimation = [self animationForHeadLayerWithBeginPosition:self.headLayer.position endPosition:CGPointMake(_isOn?self.headLayer.position.x - _moveDistance:self.headLayer.position.x + _moveDistance, self.headLayer.position.y)];
159 | }
160 | headLayerPositionAnimation.delegate = self;
161 | [self.headLayer addAnimation:headLayerPositionAnimation forKey:@"kHeadLayerPositionAnimationKey"];
162 |
163 | CABasicAnimation * backgroundAnimation = [self animationForBackgroundColorWithBeginColor:_isOn?_onColor:_offColor endColor:_isOn?_offColor:_onColor];
164 | [self.layer addAnimation:backgroundAnimation forKey:@"kBackgroundAnimationKey"];
165 | }
166 |
167 | #pragma mark animation
168 | - (CABasicAnimation *)animationForHeadLayerWithBeginPosition:(CGPoint)beginPosition endPosition:(CGPoint)endPosition {
169 | CABasicAnimation * headLayerAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
170 | headLayerAnimation.fromValue = [NSValue valueWithCGPoint:beginPosition];
171 | headLayerAnimation.toValue = [NSValue valueWithCGPoint:endPosition];
172 | headLayerAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
173 | headLayerAnimation.duration = kAnimationDuration * 2 /3;
174 | headLayerAnimation.removedOnCompletion = NO;
175 | headLayerAnimation.fillMode = kCAFillModeForwards;
176 |
177 | return headLayerAnimation;
178 | }
179 |
180 | - (CABasicAnimation *)animationForBackgroundColorWithBeginColor:(UIColor *)beginColor endColor:(UIColor *)endColor {
181 | CABasicAnimation * backgroundColorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
182 | backgroundColorAnimation.fromValue = (id)beginColor.CGColor;
183 | backgroundColorAnimation.toValue = (id)endColor.CGColor;
184 | backgroundColorAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
185 | backgroundColorAnimation.duration = kAnimationDuration * 2 /3;
186 | backgroundColorAnimation.removedOnCompletion = NO;
187 | backgroundColorAnimation.fillMode = kCAFillModeForwards;
188 |
189 | return backgroundColorAnimation;
190 | }
191 |
192 | #pragma mark Animation Delegate
193 | - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
194 | if (flag) {
195 | isAnimating = NO;
196 | _isSwitched = YES;
197 | self.isOn = !self.isOn;
198 | if (_adSwitchDidSelectedBlock) {
199 | _adSwitchDidSelectedBlock(self.isOn);
200 | }
201 | return;
202 | }
203 | }
204 |
205 | /*
206 | // Only override drawRect: if you perform custom drawing.
207 | // An empty implementation adversely affects performance during animation.
208 | - (void)drawRect:(CGRect)rect {
209 | // Drawing code
210 | }
211 | */
212 |
213 | @end
214 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightView.h:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightView.h
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ADShadowView.h"
11 |
12 | NS_ASSUME_NONNULL_BEGIN
13 |
14 | @interface ADLightView : UIView
15 |
16 | @property (nonatomic, assign) BOOL isOn;
17 | @property (nonatomic, strong) UIImageView *lightImage;
18 | @property (nonatomic, strong) ADShadowView *shadowView;
19 | @property (nonatomic, strong) UIColor *lightColor;
20 | @property (nonatomic, assign) CGFloat scaleToValue; //光晕放大比例
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADLightView.m:
--------------------------------------------------------------------------------
1 | //
2 | // ADLightView.m
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #import "ADLightView.h"
10 |
11 | @interface ADLightView ()
12 |
13 |
14 |
15 | @end
16 |
17 | @implementation ADLightView
18 |
19 | - (instancetype)initWithFrame:(CGRect)frame {
20 | if (self = [super initWithFrame:frame]) {
21 | [self initConfig];
22 | [self buildLightView];
23 | }
24 | return self;
25 | }
26 |
27 | - (void)initConfig {
28 | self.backgroundColor = [UIColor clearColor];
29 | self.lightColor = [UIColor colorWithHexString:@"ffffff" alpha:1.0];
30 | self.isOn = NO;
31 | }
32 |
33 | - (void)setScaleToValue:(CGFloat)scaleToValue {
34 | _scaleToValue = scaleToValue;
35 | self.shadowView.scaleToValue = scaleToValue;
36 | [self.shadowView setNeedsDisplay];
37 | }
38 |
39 | - (void)setIsOn:(BOOL)isOn {
40 | _isOn = isOn;
41 | self.shadowView.isOn = isOn;
42 | [self.shadowView setNeedsDisplay];
43 | }
44 |
45 | - (void)setLightColor:(UIColor *)lightColor {
46 | _lightColor = lightColor;
47 | self.shadowView.shadowColor = lightColor;
48 | [self.shadowView setNeedsDisplay];
49 | }
50 |
51 | - (void)drawRect:(CGRect)rect {
52 | //绘制半圆
53 | CGContextRef context = UIGraphicsGetCurrentContext();
54 | //y填充颜色
55 | if (self.isOn) {
56 | CGContextSetFillColorWithColor(context, self.lightColor.CGColor);
57 | } else {
58 | CGContextSetFillColorWithColor(context, [UIColor colorWithHexString:@"DCDCDC" alpha:1.0].CGColor);
59 | }
60 | CGContextMoveToPoint(context, self.bounds.size.width/2, self.bounds.size.height - self.bounds.size.width/2);
61 | CGContextAddArc(context, self.bounds.size.width/2, self.bounds.size.height - self.bounds.size.width/2, self.bounds.size.width/2, M_PI, M_PI * 2, 1);
62 | CGContextClosePath(context);
63 | CGContextDrawPath(context, kCGPathFill);
64 | }
65 |
66 | - (void)buildLightView {
67 | self.lightImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [self Suit:150], [self Suit:180])];
68 | self.lightImage.image = [UIImage imageNamed:@"light"];
69 | self.lightImage.contentMode = UIViewContentModeScaleAspectFit;
70 | [self addSubview:self.lightImage];
71 |
72 | self.shadowView = [[ADShadowView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.lightImage.frame) - [self Suit:55], [self Suit:150], [self Suit:150])];
73 | self.shadowView.shadowColor = self.lightColor;
74 | [self addSubview:self.shadowView];
75 | }
76 |
77 | /**
78 | 适配 给定375屏尺寸,适配320和414屏尺寸
79 | */
80 | - (float)Suit:(float)MySuit {
81 | IS_WIDTH320 ? (MySuit = MySuit / Suit320Width) : (IS_WIDTH414 ? (MySuit = MySuit * Suit414Width) : MySuit);
82 | return MySuit;
83 | }
84 |
85 | /**
86 | 适配 给定375屏字号,适配320和414屏字号
87 | */
88 | - (float)SuitFont:(float)font {
89 | IS_WIDTH320 ? (font = font - 1) : (IS_WIDTH414 ? (font = font + 1) : font);
90 | return font;
91 | }
92 |
93 | /*
94 | // Only override drawRect: if you perform custom drawing.
95 | // An empty implementation adversely affects performance during animation.
96 | - (void)drawRect:(CGRect)rect {
97 | // Drawing code
98 | }
99 | */
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADShadowView.h:
--------------------------------------------------------------------------------
1 | //
2 | // ShadowView.h
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface ADShadowView : UIView
14 |
15 | @property (nonatomic, assign) BOOL isOn; //是否开启
16 |
17 | @property (nonatomic, strong) UIColor *shadowColor;
18 | @property (nonatomic, assign) CGFloat scaleToValue; //光晕放大比例
19 |
20 |
21 | - (void)turnOn;
22 | - (void)turnOff;
23 |
24 | @end
25 |
26 | NS_ASSUME_NONNULL_END
27 |
--------------------------------------------------------------------------------
/LightDemo/LightScene/ADShadowView.m:
--------------------------------------------------------------------------------
1 | //
2 | // ShadowView.m
3 | // SliderDemo
4 | //
5 | // Created by user on 2018/11/9.
6 | // Copyright © 2018年 user. All rights reserved.
7 | //
8 |
9 | #import "ADShadowView.h"
10 |
11 | @interface ADShadowView () {
12 | CGFloat _r;
13 | CGFloat _g;
14 | CGFloat _b;
15 | }
16 |
17 | @end
18 |
19 | @implementation ADShadowView
20 |
21 | - (instancetype)initWithFrame:(CGRect)frame {
22 | if (self = [super initWithFrame:frame]) {
23 | self.backgroundColor = [UIColor clearColor];
24 | self.scaleToValue = 0.6;
25 | }
26 | return self;
27 | }
28 |
29 | - (void)setIsOn:(BOOL)isOn {
30 | _isOn = isOn;
31 | if (isOn) {
32 | [self turnOn];
33 | } else {
34 | [self turnOff];
35 | }
36 | }
37 |
38 | - (void)setShadowColor:(UIColor *)shadowColor {
39 | _shadowColor = shadowColor;
40 |
41 | const CGFloat *components = CGColorGetComponents(shadowColor.CGColor);
42 | _r = components[0];
43 | _g = components[1];
44 | _b = components[2];
45 | }
46 |
47 | - (void)setScaleToValue:(CGFloat)scaleToValue {
48 | _scaleToValue = scaleToValue + 1;
49 | NSLog(@"scaleToValue = %lf", _scaleToValue);
50 | self.transform = CGAffineTransformMakeScale(_scaleToValue, _scaleToValue);
51 | }
52 |
53 | - (void)drawRect:(CGRect)rect {
54 | // 创建色彩空间对象
55 | CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
56 |
57 | CGGradientRef gradient;
58 | if (self.isOn) {
59 | // 创建起点和终点颜色分量的数组
60 | CGFloat colors[] = {_r,_g,_b,1.0,1.0,1.0,1.0,0.0};
61 | //形成梯形,渐变的效果
62 | gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, 2);
63 | } else {
64 | // 创建起点和终点颜色分量的数组
65 | CGFloat colors[] = {1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0}; //关灯状态,全透明不显示
66 | //形成梯形,渐变的效果
67 | gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, 2);
68 | }
69 | // 起点颜色起始圆心
70 | CGPoint start = CGPointMake(rect.size.width/2, rect.size.height/2);
71 | // 终点颜色起始圆心
72 | CGPoint end = CGPointMake(rect.size.width/2, rect.size.height/2);
73 | // 起点颜色圆形半径
74 | CGFloat startRadius = 0.0f;
75 | // 终点颜色圆形半径
76 | CGFloat endRadius = rect.size.width/2;
77 | // 获取上下文
78 | CGContextRef graCtx = UIGraphicsGetCurrentContext();
79 | // 创建一个径向渐变
80 | CGContextDrawRadialGradient(graCtx, gradient, start, startRadius, end, endRadius, 0);
81 |
82 | //releas
83 | CGGradientRelease(gradient);
84 | gradient = NULL;
85 | CGColorSpaceRelease(rgb);
86 |
87 | [self turnOn];
88 | }
89 |
90 | - (void)turnOn {
91 | //缩放
92 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
93 | animation.fromValue = [NSNumber numberWithFloat:self.scaleToValue];
94 | animation.toValue = [NSNumber numberWithFloat:self.scaleToValue - 0.1];
95 | animation.duration = 3.0;
96 | animation.autoreverses = YES;
97 | animation.repeatCount = MAXFLOAT;
98 | animation.removedOnCompletion = NO;
99 | animation.fillMode = kCAFillModeForwards;
100 | [self.layer addAnimation:animation forKey:@"zoom"];
101 | }
102 |
103 | - (void)turnOff {
104 | [self.layer removeAllAnimations];
105 | }
106 |
107 |
108 | /*
109 | // Only override drawRect: if you perform custom drawing.
110 | // An empty implementation adversely affects performance during animation.
111 | - (void)drawRect:(CGRect)rect {
112 | // Drawing code
113 | }
114 | */
115 |
116 | @end
117 |
--------------------------------------------------------------------------------
/LightDemo/LightViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LightViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/LightDemo/LightViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. All rights reserved.
7 | //
8 |
9 | #import "LightViewController.h"
10 | #import "ADLightSwitch.h"
11 | #import "ADLightSlider.h"
12 | #import "ADLightView.h"
13 | #import "ADColorPicker.h"
14 |
15 | @interface LightViewController ()
16 |
17 | @property (nonatomic, strong) ADLightSlider *slider;
18 | @property (nonatomic, strong) ADLightView *lightView;
19 |
20 | @end
21 |
22 | @implementation LightViewController
23 |
24 | - (void)viewDidLoad {
25 | [super viewDidLoad];
26 | // Do any additional setup after loading the view, typically from a nib.
27 | [self initConfig];
28 | [self buildLightScene];
29 | }
30 |
31 | - (void)initConfig {
32 | self.view.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:1.0];
33 | }
34 |
35 | - (void)buildLightScene {
36 | //灯泡
37 | self.lightView = [[ADLightView alloc] initWithFrame:CGRectMake(ScreenWidth/2 - [self Suit:75], 64 + [self Suit:40], [self Suit:150], [self Suit:255])];
38 | self.lightView.isOn = YES;
39 | self.lightView.scaleToValue = 0.8;
40 | [self.view addSubview:self.lightView];
41 |
42 | //灯泡线
43 | UIView *line = [[UIView alloc] init];
44 | line.backgroundColor = [UIColor colorWithHexString:@"DCDCDC" alpha:1.0];
45 | [self.view addSubview:line];
46 | [line mas_makeConstraints:^(MASConstraintMaker *make) {
47 | make.centerX.equalTo(self.lightView.mas_centerX);
48 | make.bottom.equalTo(self.lightView.mas_top);
49 | make.width.mas_equalTo([self Suit:3]);
50 | make.top.equalTo(self.view.mas_top);
51 | }];
52 |
53 | //开关
54 | ADLightSwitch *lightSwitch = [[ADLightSwitch alloc] initWithFrame:CGRectMake(ScreenWidth - [self Suit:60], [self Suit:100], [self Suit:36], [self Suit:90])];
55 | lightSwitch.isOn = self.lightView.isOn;
56 | [lightSwitch setADSwitchDidSelectedBlock:^(BOOL isOn) {
57 | if (isOn) {
58 | NSLog(@"开");
59 | self.lightView.isOn = YES;
60 | [self.lightView setNeedsDisplay];
61 | } else {
62 | NSLog(@"关");
63 | self.lightView.isOn = NO;
64 | [self.lightView setNeedsDisplay];
65 | }
66 | }];
67 | [self.view addSubview:lightSwitch];
68 |
69 | //滑杆
70 | self.slider = [[ADLightSlider alloc] initWithFrame:CGRectMake([self Suit:30], ScreenHeight - [self Suit:180], [self Suit:60], [self Suit:160])];
71 | self.slider.delegate = self;
72 | self.slider.value = self.lightView.scaleToValue;
73 | [self.view addSubview:self.slider];
74 |
75 | //颜色选择
76 | ADColorPicker *colorPicker = [[ADColorPicker alloc] initWithFrame:CGRectMake(ScreenWidth - [self Suit:210], ScreenHeight - [self Suit:200], [self Suit:180], [self Suit:180])];
77 | colorPicker.delegate = self;
78 | [self.view addSubview:colorPicker];
79 | }
80 |
81 | #pragma mark - ADColorPickerDelegate
82 | - (void)getCurrentColor:(UIColor *)color {
83 | self.slider.slideColor = color;
84 | self.lightView.lightColor = color;
85 | [self.lightView setNeedsDisplay];
86 | }
87 |
88 | #pragma mark - ADSliderDelegate
89 | - (void)getCurrentSliderValue:(CGFloat)value {
90 | self.lightView.scaleToValue = value;
91 | [self.lightView setNeedsDisplay];
92 | }
93 |
94 | /**
95 | 适配 给定375屏尺寸,适配320和414屏尺寸
96 | */
97 | - (float)Suit:(float)MySuit {
98 | IS_WIDTH320 ? (MySuit = MySuit / Suit320Width) : (IS_WIDTH414 ? (MySuit = MySuit * Suit414Width) : MySuit);
99 | return MySuit;
100 | }
101 |
102 | /**
103 | 适配 给定375屏字号,适配320和414屏字号
104 | */
105 | - (float)SuitFont:(float)font {
106 | IS_WIDTH320 ? (font = font - 1) : (IS_WIDTH414 ? (font = font + 1) : font);
107 | return font;
108 | }
109 |
110 |
111 | @end
112 |
--------------------------------------------------------------------------------
/LightDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // LightDemo
4 | //
5 | // Created by user on 2018/11/14.
6 | // Copyright © 2018年 adu. 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 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | target 'LightDemo' do
5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
6 | # use_frameworks!
7 |
8 | # Pods for LightDemo
9 |
10 | pod 'Masonry'
11 | pod 'MJExtension'
12 |
13 | end
14 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Masonry (1.1.0)
3 | - MJExtension (3.0.15.1)
4 |
5 | DEPENDENCIES:
6 | - Masonry
7 | - MJExtension
8 |
9 | SPEC REPOS:
10 | https://github.com/cocoapods/specs.git:
11 | - Masonry
12 | - MJExtension
13 |
14 | SPEC CHECKSUMS:
15 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
16 | MJExtension: 19bc33ce2eee2d319760f5622562cf581a6ff756
17 |
18 | PODFILE CHECKSUM: 05529d8ba11186e73049a58d7924cac3c6b11ac0
19 |
20 | COCOAPODS: 1.5.3
21 |
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJExtension.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJExtension.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJExtensionConst.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJExtensionConst.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJFoundation.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJFoundation.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJProperty.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJProperty.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJPropertyKey.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJPropertyKey.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/MJPropertyType.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJPropertyType.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/NSObject+MJClass.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJClass.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/NSObject+MJCoding.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJCoding.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/NSObject+MJKeyValue.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJKeyValue.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/NSObject+MJProperty.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJProperty.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/MJExtension/NSString+MJExtension.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSString+MJExtension.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASCompositeConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint+Private.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraintMaker.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASLayoutConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASUtilities.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASUtilities.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewAttribute.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/Masonry.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJExtension.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJExtension.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJExtensionConst.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJExtensionConst.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJFoundation.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJFoundation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJProperty.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJProperty.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJPropertyKey.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJPropertyKey.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/MJPropertyType.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/MJPropertyType.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/NSObject+MJClass.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJClass.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/NSObject+MJCoding.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJCoding.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/NSObject+MJKeyValue.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJKeyValue.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/NSObject+MJProperty.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSObject+MJProperty.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/MJExtension/NSString+MJExtension.h:
--------------------------------------------------------------------------------
1 | ../../../MJExtension/MJExtension/NSString+MJExtension.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASCompositeConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint+Private.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASConstraintMaker.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASLayoutConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASUtilities.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASUtilities.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewAttribute.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/MASViewConstraint.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/Masonry.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h
--------------------------------------------------------------------------------
/Pods/MJExtension/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013-2015 MJExtension (https://github.com/CoderMJLee/MJExtension)
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.
20 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJExtension.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 代码地址:https://github.com/CoderMJLee/MJExtension
8 | // 代码地址:http://code4app.com/ios/%E5%AD%97%E5%85%B8-JSON-%E4%B8%8E%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%BD%AC%E6%8D%A2/5339992a933bf062608b4c57
9 |
10 | #import "NSObject+MJCoding.h"
11 | #import "NSObject+MJProperty.h"
12 | #import "NSObject+MJClass.h"
13 | #import "NSObject+MJKeyValue.h"
14 | #import "NSString+MJExtension.h"
15 | #import "MJExtensionConst.h"
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJExtensionConst.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __MJExtensionConst__H__
3 | #define __MJExtensionConst__H__
4 |
5 | #import
6 |
7 | // 信号量
8 | #define MJExtensionSemaphoreCreate \
9 | static dispatch_semaphore_t signalSemaphore; \
10 | static dispatch_once_t onceTokenSemaphore; \
11 | dispatch_once(&onceTokenSemaphore, ^{ \
12 | signalSemaphore = dispatch_semaphore_create(1); \
13 | });
14 |
15 | #define MJExtensionSemaphoreWait \
16 | dispatch_semaphore_wait(signalSemaphore, DISPATCH_TIME_FOREVER);
17 |
18 | #define MJExtensionSemaphoreSignal \
19 | dispatch_semaphore_signal(signalSemaphore);
20 |
21 | // 过期
22 | #define MJExtensionDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
23 |
24 | // 构建错误
25 | #define MJExtensionBuildError(clazz, msg) \
26 | NSError *error = [NSError errorWithDomain:msg code:250 userInfo:nil]; \
27 | [clazz setMj_error:error];
28 |
29 | // 日志输出
30 | #ifdef DEBUG
31 | #define MJExtensionLog(...) NSLog(__VA_ARGS__)
32 | #else
33 | #define MJExtensionLog(...)
34 | #endif
35 |
36 | /**
37 | * 断言
38 | * @param condition 条件
39 | * @param returnValue 返回值
40 | */
41 | #define MJExtensionAssertError(condition, returnValue, clazz, msg) \
42 | [clazz setMj_error:nil]; \
43 | if ((condition) == NO) { \
44 | MJExtensionBuildError(clazz, msg); \
45 | return returnValue;\
46 | }
47 |
48 | #define MJExtensionAssert2(condition, returnValue) \
49 | if ((condition) == NO) return returnValue;
50 |
51 | /**
52 | * 断言
53 | * @param condition 条件
54 | */
55 | #define MJExtensionAssert(condition) MJExtensionAssert2(condition, )
56 |
57 | /**
58 | * 断言
59 | * @param param 参数
60 | * @param returnValue 返回值
61 | */
62 | #define MJExtensionAssertParamNotNil2(param, returnValue) \
63 | MJExtensionAssert2((param) != nil, returnValue)
64 |
65 | /**
66 | * 断言
67 | * @param param 参数
68 | */
69 | #define MJExtensionAssertParamNotNil(param) MJExtensionAssertParamNotNil2(param, )
70 |
71 | /**
72 | * 打印所有的属性
73 | */
74 | #define MJLogAllIvars \
75 | -(NSString *)description \
76 | { \
77 | return [self mj_keyValues].description; \
78 | }
79 | #define MJExtensionLogAllProperties MJLogAllIvars
80 |
81 | /**
82 | * 类型(属性类型)
83 | */
84 | extern NSString *const MJPropertyTypeInt;
85 | extern NSString *const MJPropertyTypeShort;
86 | extern NSString *const MJPropertyTypeFloat;
87 | extern NSString *const MJPropertyTypeDouble;
88 | extern NSString *const MJPropertyTypeLong;
89 | extern NSString *const MJPropertyTypeLongLong;
90 | extern NSString *const MJPropertyTypeChar;
91 | extern NSString *const MJPropertyTypeBOOL1;
92 | extern NSString *const MJPropertyTypeBOOL2;
93 | extern NSString *const MJPropertyTypePointer;
94 |
95 | extern NSString *const MJPropertyTypeIvar;
96 | extern NSString *const MJPropertyTypeMethod;
97 | extern NSString *const MJPropertyTypeBlock;
98 | extern NSString *const MJPropertyTypeClass;
99 | extern NSString *const MJPropertyTypeSEL;
100 | extern NSString *const MJPropertyTypeId;
101 |
102 | #endif
103 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJExtensionConst.m:
--------------------------------------------------------------------------------
1 | #ifndef __MJExtensionConst__M__
2 | #define __MJExtensionConst__M__
3 |
4 | #import
5 |
6 | /**
7 | * 成员变量类型(属性类型)
8 | */
9 | NSString *const MJPropertyTypeInt = @"i";
10 | NSString *const MJPropertyTypeShort = @"s";
11 | NSString *const MJPropertyTypeFloat = @"f";
12 | NSString *const MJPropertyTypeDouble = @"d";
13 | NSString *const MJPropertyTypeLong = @"l";
14 | NSString *const MJPropertyTypeLongLong = @"q";
15 | NSString *const MJPropertyTypeChar = @"c";
16 | NSString *const MJPropertyTypeBOOL1 = @"c";
17 | NSString *const MJPropertyTypeBOOL2 = @"b";
18 | NSString *const MJPropertyTypePointer = @"*";
19 |
20 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}";
21 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}";
22 | NSString *const MJPropertyTypeBlock = @"@?";
23 | NSString *const MJPropertyTypeClass = @"#";
24 | NSString *const MJPropertyTypeSEL = @":";
25 | NSString *const MJPropertyTypeId = @"@";
26 |
27 | #endif
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJFoundation.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJFoundation : NSObject
12 | + (BOOL)isClassFromFoundation:(Class)c;
13 | @end
14 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJFoundation.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJFoundation.h"
10 | #import "MJExtensionConst.h"
11 | #import
12 |
13 | @implementation MJFoundation
14 |
15 | + (BOOL)isClassFromFoundation:(Class)c
16 | {
17 | if (c == [NSObject class] || c == [NSManagedObject class]) return YES;
18 |
19 | static NSSet *foundationClasses;
20 | static dispatch_once_t onceToken;
21 | dispatch_once(&onceToken, ^{
22 | // 集合中没有NSObject,因为几乎所有的类都是继承自NSObject,具体是不是NSObject需要特殊判断
23 | foundationClasses = [NSSet setWithObjects:
24 | [NSURL class],
25 | [NSDate class],
26 | [NSValue class],
27 | [NSData class],
28 | [NSError class],
29 | [NSArray class],
30 | [NSDictionary class],
31 | [NSString class],
32 | [NSAttributedString class], nil];
33 | });
34 |
35 | __block BOOL result = NO;
36 | [foundationClasses enumerateObjectsUsingBlock:^(Class foundationClass, BOOL *stop) {
37 | if ([c isSubclassOfClass:foundationClass]) {
38 | result = YES;
39 | *stop = YES;
40 | }
41 | }];
42 | return result;
43 | }
44 | @end
45 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | // 包装一个成员属性
8 |
9 | #import
10 | #import
11 | #import "MJPropertyType.h"
12 | #import "MJPropertyKey.h"
13 |
14 | /**
15 | * 包装一个成员
16 | */
17 | @interface MJProperty : NSObject
18 | /** 成员属性 */
19 | @property (nonatomic, assign) objc_property_t property;
20 | /** 成员属性的名字 */
21 | @property (nonatomic, readonly) NSString *name;
22 |
23 | /** 成员属性的类型 */
24 | @property (nonatomic, readonly) MJPropertyType *type;
25 | /** 成员属性来源于哪个类(可能是父类) */
26 | @property (nonatomic, assign) Class srcClass;
27 |
28 | /**** 同一个成员属性 - 父类和子类的行为可能不一致(originKey、propertyKeys、objectClassInArray) ****/
29 | /** 设置最原始的key */
30 | - (void)setOriginKey:(id)originKey forClass:(Class)c;
31 | /** 对应着字典中的多级key(里面存放的数组,数组里面都是MJPropertyKey对象) */
32 | - (NSArray *)propertyKeysForClass:(Class)c;
33 |
34 | /** 模型数组中的模型类型 */
35 | - (void)setObjectClassInArray:(Class)objectClass forClass:(Class)c;
36 | - (Class)objectClassInArrayForClass:(Class)c;
37 | /**** 同一个成员变量 - 父类和子类的行为可能不一致(key、keys、objectClassInArray) ****/
38 |
39 | /**
40 | * 设置object的成员变量值
41 | */
42 | - (void)setValue:(id)value forObject:(id)object;
43 | /**
44 | * 得到object的成员属性值
45 | */
46 | - (id)valueForObject:(id)object;
47 |
48 | /**
49 | * 初始化
50 | */
51 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property;
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJProperty.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJProperty.h"
10 | #import "MJFoundation.h"
11 | #import "MJExtensionConst.h"
12 | #import
13 |
14 | @interface MJProperty()
15 | @property (strong, nonatomic) NSMutableDictionary *propertyKeysDict;
16 | @property (strong, nonatomic) NSMutableDictionary *objectClassInArrayDict;
17 | @end
18 |
19 | @implementation MJProperty
20 |
21 | #pragma mark - 初始化
22 | - (instancetype)init
23 | {
24 | if (self = [super init]) {
25 | _propertyKeysDict = [NSMutableDictionary dictionary];
26 | _objectClassInArrayDict = [NSMutableDictionary dictionary];
27 | }
28 | return self;
29 | }
30 |
31 | #pragma mark - 缓存
32 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property
33 | {
34 | MJExtensionSemaphoreCreate
35 | MJExtensionSemaphoreWait
36 | MJProperty *propertyObj = objc_getAssociatedObject(self, property);
37 | if (propertyObj == nil) {
38 | propertyObj = [[self alloc] init];
39 | propertyObj.property = property;
40 | objc_setAssociatedObject(self, property, propertyObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
41 | }
42 | MJExtensionSemaphoreSignal
43 | return propertyObj;
44 | }
45 |
46 | #pragma mark - 公共方法
47 | - (void)setProperty:(objc_property_t)property
48 | {
49 | _property = property;
50 |
51 | MJExtensionAssertParamNotNil(property);
52 |
53 | // 1.属性名
54 | _name = @(property_getName(property));
55 |
56 | // 2.成员类型
57 | NSString *attrs = @(property_getAttributes(property));
58 | NSUInteger dotLoc = [attrs rangeOfString:@","].location;
59 | NSString *code = nil;
60 | NSUInteger loc = 1;
61 | if (dotLoc == NSNotFound) { // 没有,
62 | code = [attrs substringFromIndex:loc];
63 | } else {
64 | code = [attrs substringWithRange:NSMakeRange(loc, dotLoc - loc)];
65 | }
66 | _type = [MJPropertyType cachedTypeWithCode:code];
67 | }
68 |
69 | /**
70 | * 获得成员变量的值
71 | */
72 | - (id)valueForObject:(id)object
73 | {
74 | if (self.type.KVCDisabled) return [NSNull null];
75 | return [object valueForKey:self.name];
76 | }
77 |
78 | /**
79 | * 设置成员变量的值
80 | */
81 | - (void)setValue:(id)value forObject:(id)object
82 | {
83 | if (self.type.KVCDisabled || value == nil) return;
84 | [object setValue:value forKey:self.name];
85 | }
86 |
87 | /**
88 | * 通过字符串key创建对应的keys
89 | */
90 | - (NSArray *)propertyKeysWithStringKey:(NSString *)stringKey
91 | {
92 | if (stringKey.length == 0) return nil;
93 |
94 | NSMutableArray *propertyKeys = [NSMutableArray array];
95 | // 如果有多级映射
96 | NSArray *oldKeys = [stringKey componentsSeparatedByString:@"."];
97 |
98 | for (NSString *oldKey in oldKeys) {
99 | NSUInteger start = [oldKey rangeOfString:@"["].location;
100 | if (start != NSNotFound) { // 有索引的key
101 | NSString *prefixKey = [oldKey substringToIndex:start];
102 | NSString *indexKey = prefixKey;
103 | if (prefixKey.length) {
104 | MJPropertyKey *propertyKey = [[MJPropertyKey alloc] init];
105 | propertyKey.name = prefixKey;
106 | [propertyKeys addObject:propertyKey];
107 |
108 | indexKey = [oldKey stringByReplacingOccurrencesOfString:prefixKey withString:@""];
109 | }
110 |
111 | /** 解析索引 **/
112 | // 元素
113 | NSArray *cmps = [[indexKey stringByReplacingOccurrencesOfString:@"[" withString:@""] componentsSeparatedByString:@"]"];
114 | for (NSInteger i = 0; i
10 |
11 | typedef enum {
12 | MJPropertyKeyTypeDictionary = 0, // 字典的key
13 | MJPropertyKeyTypeArray // 数组的key
14 | } MJPropertyKeyType;
15 |
16 | /**
17 | * 属性的key
18 | */
19 | @interface MJPropertyKey : NSObject
20 | /** key的名字 */
21 | @property (copy, nonatomic) NSString *name;
22 | /** key的种类,可能是@"10",可能是@"age" */
23 | @property (assign, nonatomic) MJPropertyKeyType type;
24 |
25 | /**
26 | * 根据当前的key,也就是name,从object(字典或者数组)中取值
27 | */
28 | - (id)valueInObject:(id)object;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJPropertyKey.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyKey.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJPropertyKey.h"
10 |
11 | @implementation MJPropertyKey
12 |
13 | - (id)valueInObject:(id)object
14 | {
15 | if ([object isKindOfClass:[NSDictionary class]] && self.type == MJPropertyKeyTypeDictionary) {
16 | return object[self.name];
17 | } else if ([object isKindOfClass:[NSArray class]] && self.type == MJPropertyKeyTypeArray) {
18 | NSArray *array = object;
19 | NSUInteger index = self.name.intValue;
20 | if (index < array.count) return array[index];
21 | return nil;
22 | }
23 | return nil;
24 | }
25 | @end
26 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJPropertyType.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyType.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 包装一种类型
8 |
9 | #import
10 |
11 | /**
12 | * 包装一种类型
13 | */
14 | @interface MJPropertyType : NSObject
15 | /** 类型标识符 */
16 | @property (nonatomic, copy) NSString *code;
17 |
18 | /** 是否为id类型 */
19 | @property (nonatomic, readonly, getter=isIdType) BOOL idType;
20 |
21 | /** 是否为基本数字类型:int、float等 */
22 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType;
23 |
24 | /** 是否为BOOL类型 */
25 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType;
26 |
27 | /** 对象类型(如果是基本数据类型,此值为nil) */
28 | @property (nonatomic, readonly) Class typeClass;
29 |
30 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */
31 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation;
32 | /** 类型是否不支持KVC */
33 | @property (nonatomic, readonly, getter = isKVCDisabled) BOOL KVCDisabled;
34 |
35 | /**
36 | * 获得缓存的类型对象
37 | */
38 | + (instancetype)cachedTypeWithCode:(NSString *)code;
39 | @end
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/MJPropertyType.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyType.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJPropertyType.h"
10 | #import "MJExtension.h"
11 | #import "MJFoundation.h"
12 | #import "MJExtensionConst.h"
13 |
14 | @implementation MJPropertyType
15 |
16 | + (instancetype)cachedTypeWithCode:(NSString *)code
17 | {
18 | MJExtensionAssertParamNotNil2(code, nil);
19 |
20 | static NSMutableDictionary *types;
21 | static dispatch_once_t onceToken;
22 | dispatch_once(&onceToken, ^{
23 | types = [NSMutableDictionary dictionary];
24 | });
25 |
26 | MJExtensionSemaphoreCreate
27 | MJExtensionSemaphoreWait
28 | MJPropertyType *type = types[code];
29 | if (type == nil) {
30 | type = [[self alloc] init];
31 | type.code = code;
32 | types[code] = type;
33 | }
34 | MJExtensionSemaphoreSignal
35 | return type;
36 | }
37 |
38 | #pragma mark - 公共方法
39 | - (void)setCode:(NSString *)code
40 | {
41 | _code = code;
42 |
43 | MJExtensionAssertParamNotNil(code);
44 |
45 | if ([code isEqualToString:MJPropertyTypeId]) {
46 | _idType = YES;
47 | } else if (code.length == 0) {
48 | _KVCDisabled = YES;
49 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) {
50 | // 去掉@"和",截取中间的类型名称
51 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)];
52 | _typeClass = NSClassFromString(_code);
53 | _fromFoundation = [MJFoundation isClassFromFoundation:_typeClass];
54 | _numberType = [_typeClass isSubclassOfClass:[NSNumber class]];
55 |
56 | } else if ([code isEqualToString:MJPropertyTypeSEL] ||
57 | [code isEqualToString:MJPropertyTypeIvar] ||
58 | [code isEqualToString:MJPropertyTypeMethod]) {
59 | _KVCDisabled = YES;
60 | }
61 |
62 | // 是否为数字类型
63 | NSString *lowerCode = _code.lowercaseString;
64 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeLongLong, MJPropertyTypeChar];
65 | if ([numberTypes containsObject:lowerCode]) {
66 | _numberType = YES;
67 |
68 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1]
69 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) {
70 | _boolType = YES;
71 | }
72 | }
73 | }
74 | @end
75 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSObject+MJClass.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJClass.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /**
12 | * 遍历所有类的block(父类)
13 | */
14 | typedef void (^MJClassesEnumeration)(Class c, BOOL *stop);
15 |
16 | /** 这个数组中的属性名才会进行字典和模型的转换 */
17 | typedef NSArray * (^MJAllowedPropertyNames)(void);
18 | /** 这个数组中的属性名才会进行归档 */
19 | typedef NSArray * (^MJAllowedCodingPropertyNames)(void);
20 |
21 | /** 这个数组中的属性名将会被忽略:不进行字典和模型的转换 */
22 | typedef NSArray * (^MJIgnoredPropertyNames)(void);
23 | /** 这个数组中的属性名将会被忽略:不进行归档 */
24 | typedef NSArray * (^MJIgnoredCodingPropertyNames)(void);
25 |
26 | /**
27 | * 类相关的扩展
28 | */
29 | @interface NSObject (MJClass)
30 | /**
31 | * 遍历所有的类
32 | */
33 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration;
34 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration;
35 |
36 | #pragma mark - 属性白名单配置
37 | /**
38 | * 这个数组中的属性名才会进行字典和模型的转换
39 | *
40 | * @param allowedPropertyNames 这个数组中的属性名才会进行字典和模型的转换
41 | */
42 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames;
43 |
44 | /**
45 | * 这个数组中的属性名才会进行字典和模型的转换
46 | */
47 | + (NSMutableArray *)mj_totalAllowedPropertyNames;
48 |
49 | #pragma mark - 属性黑名单配置
50 | /**
51 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
52 | *
53 | * @param ignoredPropertyNames 这个数组中的属性名将会被忽略:不进行字典和模型的转换
54 | */
55 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames;
56 |
57 | /**
58 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
59 | */
60 | + (NSMutableArray *)mj_totalIgnoredPropertyNames;
61 |
62 | #pragma mark - 归档属性白名单配置
63 | /**
64 | * 这个数组中的属性名才会进行归档
65 | *
66 | * @param allowedCodingPropertyNames 这个数组中的属性名才会进行归档
67 | */
68 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames;
69 |
70 | /**
71 | * 这个数组中的属性名才会进行字典和模型的转换
72 | */
73 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames;
74 |
75 | #pragma mark - 归档属性黑名单配置
76 | /**
77 | * 这个数组中的属性名将会被忽略:不进行归档
78 | *
79 | * @param ignoredCodingPropertyNames 这个数组中的属性名将会被忽略:不进行归档
80 | */
81 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames;
82 |
83 | /**
84 | * 这个数组中的属性名将会被忽略:不进行归档
85 | */
86 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames;
87 |
88 | #pragma mark - 内部使用
89 | + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key;
90 | @end
91 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSObject+MJClass.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJClass.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSObject+MJClass.h"
10 | #import "NSObject+MJCoding.h"
11 | #import "NSObject+MJKeyValue.h"
12 | #import "MJFoundation.h"
13 | #import
14 |
15 | static const char MJAllowedPropertyNamesKey = '\0';
16 | static const char MJIgnoredPropertyNamesKey = '\0';
17 | static const char MJAllowedCodingPropertyNamesKey = '\0';
18 | static const char MJIgnoredCodingPropertyNamesKey = '\0';
19 |
20 | @implementation NSObject (MJClass)
21 |
22 | + (NSMutableDictionary *)classDictForKey:(const void *)key
23 | {
24 | static NSMutableDictionary *allowedPropertyNamesDict;
25 | static NSMutableDictionary *ignoredPropertyNamesDict;
26 | static NSMutableDictionary *allowedCodingPropertyNamesDict;
27 | static NSMutableDictionary *ignoredCodingPropertyNamesDict;
28 |
29 | static dispatch_once_t onceToken;
30 | dispatch_once(&onceToken, ^{
31 | allowedPropertyNamesDict = [NSMutableDictionary dictionary];
32 | ignoredPropertyNamesDict = [NSMutableDictionary dictionary];
33 | allowedCodingPropertyNamesDict = [NSMutableDictionary dictionary];
34 | ignoredCodingPropertyNamesDict = [NSMutableDictionary dictionary];
35 | });
36 |
37 | if (key == &MJAllowedPropertyNamesKey) return allowedPropertyNamesDict;
38 | if (key == &MJIgnoredPropertyNamesKey) return ignoredPropertyNamesDict;
39 | if (key == &MJAllowedCodingPropertyNamesKey) return allowedCodingPropertyNamesDict;
40 | if (key == &MJIgnoredCodingPropertyNamesKey) return ignoredCodingPropertyNamesDict;
41 | return nil;
42 | }
43 |
44 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration
45 | {
46 | // 1.没有block就直接返回
47 | if (enumeration == nil) return;
48 |
49 | // 2.停止遍历的标记
50 | BOOL stop = NO;
51 |
52 | // 3.当前正在遍历的类
53 | Class c = self;
54 |
55 | // 4.开始遍历每一个类
56 | while (c && !stop) {
57 | // 4.1.执行操作
58 | enumeration(c, &stop);
59 |
60 | // 4.2.获得父类
61 | c = class_getSuperclass(c);
62 |
63 | if ([MJFoundation isClassFromFoundation:c]) break;
64 | }
65 | }
66 |
67 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration
68 | {
69 | // 1.没有block就直接返回
70 | if (enumeration == nil) return;
71 |
72 | // 2.停止遍历的标记
73 | BOOL stop = NO;
74 |
75 | // 3.当前正在遍历的类
76 | Class c = self;
77 |
78 | // 4.开始遍历每一个类
79 | while (c && !stop) {
80 | // 4.1.执行操作
81 | enumeration(c, &stop);
82 |
83 | // 4.2.获得父类
84 | c = class_getSuperclass(c);
85 | }
86 | }
87 |
88 | #pragma mark - 属性黑名单配置
89 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames
90 | {
91 | [self mj_setupBlockReturnValue:ignoredPropertyNames key:&MJIgnoredPropertyNamesKey];
92 | }
93 |
94 | + (NSMutableArray *)mj_totalIgnoredPropertyNames
95 | {
96 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredPropertyNames) key:&MJIgnoredPropertyNamesKey];
97 | }
98 |
99 | #pragma mark - 归档属性黑名单配置
100 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames
101 | {
102 | [self mj_setupBlockReturnValue:ignoredCodingPropertyNames key:&MJIgnoredCodingPropertyNamesKey];
103 | }
104 |
105 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames
106 | {
107 | return [self mj_totalObjectsWithSelector:@selector(mj_ignoredCodingPropertyNames) key:&MJIgnoredCodingPropertyNamesKey];
108 | }
109 |
110 | #pragma mark - 属性白名单配置
111 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames;
112 | {
113 | [self mj_setupBlockReturnValue:allowedPropertyNames key:&MJAllowedPropertyNamesKey];
114 | }
115 |
116 | + (NSMutableArray *)mj_totalAllowedPropertyNames
117 | {
118 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedPropertyNames) key:&MJAllowedPropertyNamesKey];
119 | }
120 |
121 | #pragma mark - 归档属性白名单配置
122 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames
123 | {
124 | [self mj_setupBlockReturnValue:allowedCodingPropertyNames key:&MJAllowedCodingPropertyNamesKey];
125 | }
126 |
127 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames
128 | {
129 | return [self mj_totalObjectsWithSelector:@selector(mj_allowedCodingPropertyNames) key:&MJAllowedCodingPropertyNamesKey];
130 | }
131 |
132 | #pragma mark - block和方法处理:存储block的返回值
133 | + (void)mj_setupBlockReturnValue:(id (^)(void))block key:(const char *)key
134 | {
135 | if (block) {
136 | objc_setAssociatedObject(self, key, block(), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
137 | } else {
138 | objc_setAssociatedObject(self, key, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
139 | }
140 |
141 | // 清空数据
142 | MJExtensionSemaphoreCreate
143 | MJExtensionSemaphoreWait
144 | [[self classDictForKey:key] removeAllObjects];
145 | MJExtensionSemaphoreSignal
146 | }
147 |
148 | + (NSMutableArray *)mj_totalObjectsWithSelector:(SEL)selector key:(const char *)key
149 | {
150 | MJExtensionSemaphoreCreate
151 | MJExtensionSemaphoreWait
152 |
153 | NSMutableArray *array = [self classDictForKey:key][NSStringFromClass(self)];
154 | if (array == nil) {
155 | // 创建、存储
156 | [self classDictForKey:key][NSStringFromClass(self)] = array = [NSMutableArray array];
157 |
158 | if ([self respondsToSelector:selector]) {
159 | #pragma clang diagnostic push
160 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
161 | NSArray *subArray = [self performSelector:selector];
162 | #pragma clang diagnostic pop
163 | if (subArray) {
164 | [array addObjectsFromArray:subArray];
165 | }
166 | }
167 |
168 | [self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
169 | NSArray *subArray = objc_getAssociatedObject(c, key);
170 | [array addObjectsFromArray:subArray];
171 | }];
172 | }
173 |
174 | MJExtensionSemaphoreSignal
175 |
176 | return array;
177 | }
178 | @end
179 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSObject+MJCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | /**
13 | * Codeing协议
14 | */
15 | @protocol MJCoding
16 | @optional
17 | /**
18 | * 这个数组中的属性名才会进行归档
19 | */
20 | + (NSArray *)mj_allowedCodingPropertyNames;
21 | /**
22 | * 这个数组中的属性名将会被忽略:不进行归档
23 | */
24 | + (NSArray *)mj_ignoredCodingPropertyNames;
25 | @end
26 |
27 | @interface NSObject (MJCoding)
28 | /**
29 | * 解码(从文件中解析对象)
30 | */
31 | - (void)mj_decode:(NSCoder *)decoder;
32 | /**
33 | * 编码(将对象写入文件中)
34 | */
35 | - (void)mj_encode:(NSCoder *)encoder;
36 | @end
37 |
38 | /**
39 | 归档的实现
40 | */
41 | #define MJCodingImplementation \
42 | - (id)initWithCoder:(NSCoder *)decoder \
43 | { \
44 | if (self = [super init]) { \
45 | [self mj_decode:decoder]; \
46 | } \
47 | return self; \
48 | } \
49 | \
50 | - (void)encodeWithCoder:(NSCoder *)encoder \
51 | { \
52 | [self mj_encode:encoder]; \
53 | }
54 |
55 | #define MJExtensionCodingImplementation MJCodingImplementation
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSObject+MJCoding.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSObject+MJCoding.h"
10 | #import "NSObject+MJClass.h"
11 | #import "NSObject+MJProperty.h"
12 | #import "MJProperty.h"
13 |
14 | @implementation NSObject (MJCoding)
15 |
16 | - (void)mj_encode:(NSCoder *)encoder
17 | {
18 | Class clazz = [self class];
19 |
20 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames];
21 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames];
22 |
23 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) {
24 | // 检测是否被忽略
25 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
26 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
27 |
28 | id value = [property valueForObject:self];
29 | if (value == nil) return;
30 | [encoder encodeObject:value forKey:property.name];
31 | }];
32 | }
33 |
34 | - (void)mj_decode:(NSCoder *)decoder
35 | {
36 | Class clazz = [self class];
37 |
38 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames];
39 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames];
40 |
41 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) {
42 | // 检测是否被忽略
43 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
44 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
45 |
46 | id value = [decoder decodeObjectForKey:property.name];
47 | if (value == nil) { // 兼容以前的MJExtension版本
48 | value = [decoder decodeObjectForKey:[@"_" stringByAppendingString:property.name]];
49 | }
50 | if (value == nil) return;
51 | [property setValue:value forObject:self];
52 | }];
53 | }
54 | @end
55 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSObject+MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | @class MJProperty;
13 |
14 | /**
15 | * 遍历成员变量用的block
16 | *
17 | * @param property 成员的包装对象
18 | * @param stop YES代表停止遍历,NO代表继续遍历
19 | */
20 | typedef void (^MJPropertiesEnumeration)(MJProperty *property, BOOL *stop);
21 |
22 | /** 将属性名换为其他key去字典中取值 */
23 | typedef NSDictionary * (^MJReplacedKeyFromPropertyName)(void);
24 | typedef id (^MJReplacedKeyFromPropertyName121)(NSString *propertyName);
25 | /** 数组中需要转换的模型类 */
26 | typedef NSDictionary * (^MJObjectClassInArray)(void);
27 | /** 用于过滤字典中的值 */
28 | typedef id (^MJNewValueFromOldValue)(id object, id oldValue, MJProperty *property);
29 |
30 | /**
31 | * 成员属性相关的扩展
32 | */
33 | @interface NSObject (MJProperty)
34 | #pragma mark - 遍历
35 | /**
36 | * 遍历所有的成员
37 | */
38 | + (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration;
39 |
40 | #pragma mark - 新值配置
41 | /**
42 | * 用于过滤字典中的值
43 | *
44 | * @param newValueFormOldValue 用于过滤字典中的值
45 | */
46 | + (void)mj_setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue;
47 | + (id)mj_getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property;
48 |
49 | #pragma mark - key配置
50 | /**
51 | * 将属性名换为其他key去字典中取值
52 | *
53 | * @param replacedKeyFromPropertyName 将属性名换为其他key去字典中取值
54 | */
55 | + (void)mj_setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName;
56 | /**
57 | * 将属性名换为其他key去字典中取值
58 | *
59 | * @param replacedKeyFromPropertyName121 将属性名换为其他key去字典中取值
60 | */
61 | + (void)mj_setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121;
62 |
63 | #pragma mark - array model class配置
64 | /**
65 | * 数组中需要转换的模型类
66 | *
67 | * @param objectClassInArray 数组中需要转换的模型类
68 | */
69 | + (void)mj_setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray;
70 | @end
71 |
72 | @interface NSObject (MJPropertyDeprecated_v_2_5_16)
73 | + (void)enumerateProperties:(MJPropertiesEnumeration)enumeration MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
74 | + (void)setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
75 | + (id)getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
76 | + (void)setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
77 | + (void)setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121 MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
78 | + (void)setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
79 | @end
80 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSString+MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+MJExtension.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/6/7.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | @interface NSString (MJExtension)
13 | /**
14 | * 驼峰转下划线(loveYou -> love_you)
15 | */
16 | - (NSString *)mj_underlineFromCamel;
17 | /**
18 | * 下划线转驼峰(love_you -> loveYou)
19 | */
20 | - (NSString *)mj_camelFromUnderline;
21 | /**
22 | * 首字母变大写
23 | */
24 | - (NSString *)mj_firstCharUpper;
25 | /**
26 | * 首字母变小写
27 | */
28 | - (NSString *)mj_firstCharLower;
29 |
30 | - (BOOL)mj_isPureInt;
31 |
32 | - (NSURL *)mj_url;
33 | @end
34 |
35 | @interface NSString (MJExtensionDeprecated_v_2_5_16)
36 | - (NSString *)underlineFromCamel MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
37 | - (NSString *)camelFromUnderline MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
38 | - (NSString *)firstCharUpper MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
39 | - (NSString *)firstCharLower MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
40 | - (BOOL)isPureInt MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
41 | - (NSURL *)url MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
42 | @end
43 |
--------------------------------------------------------------------------------
/Pods/MJExtension/MJExtension/NSString+MJExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+MJExtension.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/6/7.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSString+MJExtension.h"
10 |
11 | @implementation NSString (MJExtension)
12 | - (NSString *)mj_underlineFromCamel
13 | {
14 | if (self.length == 0) return self;
15 | NSMutableString *string = [NSMutableString string];
16 | for (NSUInteger i = 0; i= 2) [string appendString:[cmp substringFromIndex:1]];
40 | } else {
41 | [string appendString:cmp];
42 | }
43 | }
44 | return string;
45 | }
46 |
47 | - (NSString *)mj_firstCharLower
48 | {
49 | if (self.length == 0) return self;
50 | NSMutableString *string = [NSMutableString string];
51 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].lowercaseString];
52 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]];
53 | return string;
54 | }
55 |
56 | - (NSString *)mj_firstCharUpper
57 | {
58 | if (self.length == 0) return self;
59 | NSMutableString *string = [NSMutableString string];
60 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].uppercaseString];
61 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]];
62 | return string;
63 | }
64 |
65 | - (BOOL)mj_isPureInt
66 | {
67 | NSScanner *scan = [NSScanner scannerWithString:self];
68 | int val;
69 | return [scan scanInt:&val] && [scan isAtEnd];
70 | }
71 |
72 | - (NSURL *)mj_url
73 | {
74 | // [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"]];
75 | #pragma clang diagnostic push
76 | #pragma clang diagnostic ignored"-Wdeprecated-declarations"
77 | return [NSURL URLWithString:(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL,kCFStringEncodingUTF8))];
78 | #pragma clang diagnostic pop
79 | }
80 | @end
81 |
82 | @implementation NSString (MJExtensionDeprecated_v_2_5_16)
83 | - (NSString *)underlineFromCamel
84 | {
85 | return self.mj_underlineFromCamel;
86 | }
87 |
88 | - (NSString *)camelFromUnderline
89 | {
90 | return self.mj_camelFromUnderline;
91 | }
92 |
93 | - (NSString *)firstCharLower
94 | {
95 | return self.mj_firstCharLower;
96 | }
97 |
98 | - (NSString *)firstCharUpper
99 | {
100 | return self.mj_firstCharUpper;
101 | }
102 |
103 | - (BOOL)isPureInt
104 | {
105 | return self.mj_isPureInt;
106 | }
107 |
108 | - (NSURL *)url
109 | {
110 | return self.mj_url;
111 | }
112 | @end
113 |
--------------------------------------------------------------------------------
/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Masonry (1.1.0)
3 | - MJExtension (3.0.15.1)
4 |
5 | DEPENDENCIES:
6 | - Masonry
7 | - MJExtension
8 |
9 | SPEC REPOS:
10 | https://github.com/cocoapods/specs.git:
11 | - Masonry
12 | - MJExtension
13 |
14 | SPEC CHECKSUMS:
15 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
16 | MJExtension: 19bc33ce2eee2d319760f5622562cf581a6ff756
17 |
18 | PODFILE CHECKSUM: 05529d8ba11186e73049a58d7924cac3c6b11ac0
19 |
20 | COCOAPODS: 1.5.3
21 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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)setInset:(CGFloat)inset {
133 | for (MASConstraint *constraint in self.childConstraints) {
134 | constraint.inset = inset;
135 | }
136 | }
137 |
138 | - (void)setOffset:(CGFloat)offset {
139 | for (MASConstraint *constraint in self.childConstraints) {
140 | constraint.offset = offset;
141 | }
142 | }
143 |
144 | - (void)setSizeOffset:(CGSize)sizeOffset {
145 | for (MASConstraint *constraint in self.childConstraints) {
146 | constraint.sizeOffset = sizeOffset;
147 | }
148 | }
149 |
150 | - (void)setCenterOffset:(CGPoint)centerOffset {
151 | for (MASConstraint *constraint in self.childConstraints) {
152 | constraint.centerOffset = centerOffset;
153 | }
154 | }
155 |
156 | #pragma mark - MASConstraint
157 |
158 | - (void)activate {
159 | for (MASConstraint *constraint in self.childConstraints) {
160 | [constraint activate];
161 | }
162 | }
163 |
164 | - (void)deactivate {
165 | for (MASConstraint *constraint in self.childConstraints) {
166 | [constraint deactivate];
167 | }
168 | }
169 |
170 | - (void)install {
171 | for (MASConstraint *constraint in self.childConstraints) {
172 | constraint.updateExisting = self.updateExisting;
173 | [constraint install];
174 | }
175 | }
176 |
177 | - (void)uninstall {
178 | for (MASConstraint *constraint in self.childConstraints) {
179 | [constraint uninstall];
180 | }
181 | }
182 |
183 | @end
184 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintMaker.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | typedef NS_OPTIONS(NSInteger, MASAttribute) {
13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft,
14 | MASAttributeRight = 1 << NSLayoutAttributeRight,
15 | MASAttributeTop = 1 << NSLayoutAttributeTop,
16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom,
17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading,
18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth,
20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight,
21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24 |
25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
26 |
27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline,
28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline,
29 |
30 | #endif
31 |
32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
33 |
34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin,
36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin,
37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin,
38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,
42 |
43 | #endif
44 |
45 | };
46 |
47 | /**
48 | * Provides factory methods for creating MASConstraints.
49 | * Constraints are collected until they are ready to be installed
50 | *
51 | */
52 | @interface MASConstraintMaker : NSObject
53 |
54 | /**
55 | * The following properties return a new MASViewConstraint
56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute
57 | */
58 | @property (nonatomic, strong, readonly) MASConstraint *left;
59 | @property (nonatomic, strong, readonly) MASConstraint *top;
60 | @property (nonatomic, strong, readonly) MASConstraint *right;
61 | @property (nonatomic, strong, readonly) MASConstraint *bottom;
62 | @property (nonatomic, strong, readonly) MASConstraint *leading;
63 | @property (nonatomic, strong, readonly) MASConstraint *trailing;
64 | @property (nonatomic, strong, readonly) MASConstraint *width;
65 | @property (nonatomic, strong, readonly) MASConstraint *height;
66 | @property (nonatomic, strong, readonly) MASConstraint *centerX;
67 | @property (nonatomic, strong, readonly) MASConstraint *centerY;
68 | @property (nonatomic, strong, readonly) MASConstraint *baseline;
69 |
70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
71 |
72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline;
73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline;
74 |
75 | #endif
76 |
77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
78 |
79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin;
80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin;
81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin;
82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin;
83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin;
84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin;
85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins;
86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins;
87 |
88 | #endif
89 |
90 | /**
91 | * Returns a block which creates a new MASCompositeConstraint with the first item set
92 | * to the makers associated view and children corresponding to the set bits in the
93 | * MASAttribute parameter. Combine multiple attributes via binary-or.
94 | */
95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs);
96 |
97 | /**
98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges
99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right)
100 | * with the first item set to the makers associated view
101 | */
102 | @property (nonatomic, strong, readonly) MASConstraint *edges;
103 |
104 | /**
105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize
106 | * which generates the appropriate MASViewConstraint children (width, height)
107 | * with the first item set to the makers associated view
108 | */
109 | @property (nonatomic, strong, readonly) MASConstraint *size;
110 |
111 | /**
112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter
113 | * which generates the appropriate MASViewConstraint children (centerX, centerY)
114 | * with the first item set to the makers associated view
115 | */
116 | @property (nonatomic, strong, readonly) MASConstraint *center;
117 |
118 | /**
119 | * Whether or not to check for an existing constraint instead of adding constraint
120 | */
121 | @property (nonatomic, assign) BOOL updateExisting;
122 |
123 | /**
124 | * Whether or not to remove existing constraints prior to installing
125 | */
126 | @property (nonatomic, assign) BOOL removeExisting;
127 |
128 | /**
129 | * initialises the maker with a default view
130 | *
131 | * @param view any MASConstraint are created with this view as the first item
132 | *
133 | * @return a new MASConstraintMaker
134 | */
135 | - (id)initWithView:(MAS_VIEW *)view;
136 |
137 | /**
138 | * Calls install method on any MASConstraints which have been created by this maker
139 | *
140 | * @return an array of all the installed MASConstraints
141 | */
142 | - (NSArray *)install;
143 |
144 | - (MASConstraint * (^)(dispatch_block_t))group;
145 |
146 | @end
147 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASViewAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASViewAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASViewConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin",
54 | @(NSLayoutAttributeRightMargin) : @"rightMargin",
55 | @(NSLayoutAttributeTopMargin) : @"topMargin",
56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin",
57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin",
58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin",
59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins",
60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins",
61 | #endif
62 |
63 | };
64 |
65 | });
66 | return descriptionMap;
67 | }
68 |
69 |
70 | + (NSDictionary *)layoutPriorityDescriptionsByValue {
71 | static dispatch_once_t once;
72 | static NSDictionary *descriptionMap;
73 | dispatch_once(&once, ^{
74 | #if TARGET_OS_IPHONE || TARGET_OS_TV
75 | descriptionMap = @{
76 | @(MASLayoutPriorityDefaultHigh) : @"high",
77 | @(MASLayoutPriorityDefaultLow) : @"low",
78 | @(MASLayoutPriorityDefaultMedium) : @"medium",
79 | @(MASLayoutPriorityRequired) : @"required",
80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size",
81 | };
82 | #elif TARGET_OS_MAC
83 | descriptionMap = @{
84 | @(MASLayoutPriorityDefaultHigh) : @"high",
85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window",
86 | @(MASLayoutPriorityDefaultMedium) : @"medium",
87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put",
88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window",
89 | @(MASLayoutPriorityDefaultLow) : @"low",
90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size",
91 | @(MASLayoutPriorityRequired) : @"required",
92 | };
93 | #endif
94 | });
95 | return descriptionMap;
96 | }
97 |
98 | #pragma mark - description override
99 |
100 | + (NSString *)descriptionForObject:(id)obj {
101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) {
102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]];
103 | }
104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj];
105 | }
106 |
107 | - (NSString *)description {
108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"];
109 |
110 | [description appendString:[self.class descriptionForObject:self]];
111 |
112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
115 | }
116 |
117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
118 |
119 | if (self.secondItem) {
120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
121 | }
122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
124 | }
125 |
126 | if (self.multiplier != 1) {
127 | [description appendFormat:@" * %g", self.multiplier];
128 | }
129 |
130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) {
131 | [description appendFormat:@" %g", self.constant];
132 | } else {
133 | if (self.constant) {
134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)];
135 | }
136 | }
137 |
138 | if (self.priority != MASLayoutPriorityRequired) {
139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
140 | }
141 |
142 | [description appendString:@">"];
143 | return description;
144 | }
145 |
146 | @end
147 |
--------------------------------------------------------------------------------
/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
43 |
44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
52 |
53 | #endif
54 |
55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000)
56 |
57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0));
58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0));
59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0));
60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0));
61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0));
62 |
63 | #endif
64 |
65 | /**
66 | * a key to associate with this view
67 | */
68 | @property (nonatomic, strong) id mas_key;
69 |
70 | /**
71 | * Finds the closest common superview between this view and another view
72 | *
73 | * @param view other view
74 | *
75 | * @return returns nil if common superview could not be found
76 | */
77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
78 |
79 | /**
80 | * Creates a MASConstraintMaker with the callee view.
81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing
82 | *
83 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
84 | *
85 | * @return Array of created MASConstraints
86 | */
87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
88 |
89 | /**
90 | * Creates a MASConstraintMaker with the callee view.
91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
92 | * If an existing constraint exists then it will be updated instead.
93 | *
94 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
95 | *
96 | * @return Array of created/updated MASConstraints
97 | */
98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
99 |
100 | /**
101 | * Creates a MASConstraintMaker with the callee view.
102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
103 | * All constraints previously installed for the view will be removed.
104 | *
105 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
106 | *
107 | * @return Array of created/updated MASConstraints
108 | */
109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
110 |
111 | @end
112 |
--------------------------------------------------------------------------------
/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
102 |
103 | - (MASViewAttribute *)mas_leftMargin {
104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin];
105 | }
106 |
107 | - (MASViewAttribute *)mas_rightMargin {
108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin];
109 | }
110 |
111 | - (MASViewAttribute *)mas_topMargin {
112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin];
113 | }
114 |
115 | - (MASViewAttribute *)mas_bottomMargin {
116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin];
117 | }
118 |
119 | - (MASViewAttribute *)mas_leadingMargin {
120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin];
121 | }
122 |
123 | - (MASViewAttribute *)mas_trailingMargin {
124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin];
125 | }
126 |
127 | - (MASViewAttribute *)mas_centerXWithinMargins {
128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins];
129 | }
130 |
131 | - (MASViewAttribute *)mas_centerYWithinMargins {
132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
133 | }
134 |
135 | #endif
136 |
137 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000)
138 |
139 | - (MASViewAttribute *)mas_safeAreaLayoutGuide {
140 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
141 | }
142 | - (MASViewAttribute *)mas_safeAreaLayoutGuideTop {
143 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop];
144 | }
145 | - (MASViewAttribute *)mas_safeAreaLayoutGuideBottom {
146 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
147 | }
148 | - (MASViewAttribute *)mas_safeAreaLayoutGuideLeft {
149 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft];
150 | }
151 | - (MASViewAttribute *)mas_safeAreaLayoutGuideRight {
152 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight];
153 | }
154 |
155 | #endif
156 |
157 | #pragma mark - associated properties
158 |
159 | - (id)mas_key {
160 | return objc_getAssociatedObject(self, @selector(mas_key));
161 | }
162 |
163 | - (void)setMas_key:(id)key {
164 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
165 | }
166 |
167 | #pragma mark - heirachy
168 |
169 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
170 | MAS_VIEW *closestCommonSuperview = nil;
171 |
172 | MAS_VIEW *secondViewSuperview = view;
173 | while (!closestCommonSuperview && secondViewSuperview) {
174 | MAS_VIEW *firstViewSuperview = self;
175 | while (!closestCommonSuperview && firstViewSuperview) {
176 | if (secondViewSuperview == firstViewSuperview) {
177 | closestCommonSuperview = secondViewSuperview;
178 | }
179 | firstViewSuperview = firstViewSuperview.superview;
180 | }
181 | secondViewSuperview = secondViewSuperview.superview;
182 | }
183 | return closestCommonSuperview;
184 | }
185 |
186 | @end
187 |
--------------------------------------------------------------------------------
/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 (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
40 |
41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin;
43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin;
44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin;
45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin;
46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin;
47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins;
48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins;
49 |
50 | #endif
51 |
52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000)
53 |
54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0));
55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0));
56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0));
57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0));
58 |
59 | #endif
60 |
61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
64 |
65 | @end
66 |
67 | #define MAS_ATTR_FORWARD(attr) \
68 | - (MASViewAttribute *)attr { \
69 | return [self mas_##attr]; \
70 | }
71 |
72 | @implementation MAS_VIEW (MASShorthandAdditions)
73 |
74 | MAS_ATTR_FORWARD(top);
75 | MAS_ATTR_FORWARD(left);
76 | MAS_ATTR_FORWARD(bottom);
77 | MAS_ATTR_FORWARD(right);
78 | MAS_ATTR_FORWARD(leading);
79 | MAS_ATTR_FORWARD(trailing);
80 | MAS_ATTR_FORWARD(width);
81 | MAS_ATTR_FORWARD(height);
82 | MAS_ATTR_FORWARD(centerX);
83 | MAS_ATTR_FORWARD(centerY);
84 | MAS_ATTR_FORWARD(baseline);
85 |
86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
87 |
88 | MAS_ATTR_FORWARD(firstBaseline);
89 | MAS_ATTR_FORWARD(lastBaseline);
90 |
91 | #endif
92 |
93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
94 |
95 | MAS_ATTR_FORWARD(leftMargin);
96 | MAS_ATTR_FORWARD(rightMargin);
97 | MAS_ATTR_FORWARD(topMargin);
98 | MAS_ATTR_FORWARD(bottomMargin);
99 | MAS_ATTR_FORWARD(leadingMargin);
100 | MAS_ATTR_FORWARD(trailingMargin);
101 | MAS_ATTR_FORWARD(centerXWithinMargins);
102 | MAS_ATTR_FORWARD(centerYWithinMargins);
103 |
104 | #endif
105 |
106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000)
107 |
108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop);
109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom);
110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft);
111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight);
112 |
113 | #endif
114 |
115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
116 | return [self mas_attribute];
117 | }
118 |
119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
120 | return [self mas_makeConstraints:block];
121 | }
122 |
123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
124 | return [self mas_updateConstraints:block];
125 | }
126 |
127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
128 | return [self mas_remakeConstraints:block];
129 | }
130 |
131 | @end
132 |
133 | #endif
134 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/MJExtension.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
45 |
46 |
52 |
53 |
55 |
56 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Masonry.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
45 |
46 |
52 |
53 |
55 |
56 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Pods-LightDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
45 |
46 |
52 |
53 |
55 |
56 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MJExtension.xcscheme
8 |
9 | isShown
10 |
11 | orderHint
12 | 1
13 |
14 | Masonry.xcscheme
15 |
16 | isShown
17 |
18 | orderHint
19 | 0
20 |
21 | Pods-LightDemo.xcscheme
22 |
23 | isShown
24 |
25 | orderHint
26 | 2
27 |
28 |
29 | SuppressBuildableAutocreation
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/MJExtension/MJExtension-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_MJExtension : NSObject
3 | @end
4 | @implementation PodsDummy_MJExtension
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/MJExtension/MJExtension-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/MJExtension/MJExtension.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/MJExtension
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MJExtension" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MJExtension"
4 | PODS_BUILD_DIR = ${BUILD_DIR}
5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJExtension
8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
9 | SKIP_INSTALL = YES
10 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Masonry/Masonry-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Masonry : NSObject
3 | @end
4 | @implementation PodsDummy_Masonry
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Masonry/Masonry-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #else
4 | #ifndef FOUNDATION_EXPORT
5 | #if defined(__cplusplus)
6 | #define FOUNDATION_EXPORT extern "C"
7 | #else
8 | #define FOUNDATION_EXPORT extern
9 | #endif
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/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 = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry"
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 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry
9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
10 | SKIP_INSTALL = YES
11 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## MJExtension
5 |
6 | Copyright (c) 2013-2015 MJExtension (https://github.com/CoderMJLee/MJExtension)
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 |
27 | ## Masonry
28 |
29 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
30 |
31 | Permission is hereby granted, free of charge, to any person obtaining a copy
32 | of this software and associated documentation files (the "Software"), to deal
33 | in the Software without restriction, including without limitation the rights
34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35 | copies of the Software, and to permit persons to whom the Software is
36 | furnished to do so, subject to the following conditions:
37 |
38 | The above copyright notice and this permission notice shall be included in
39 | all copies or substantial portions of the Software.
40 |
41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47 | THE SOFTWARE.
48 | Generated by CocoaPods - https://cocoapods.org
49 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo-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 | Copyright (c) 2013-2015 MJExtension (https://github.com/CoderMJLee/MJExtension)
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | License
38 | MIT
39 | Title
40 | MJExtension
41 | Type
42 | PSGroupSpecifier
43 |
44 |
45 | FooterText
46 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
47 |
48 | Permission is hereby granted, free of charge, to any person obtaining a copy
49 | of this software and associated documentation files (the "Software"), to deal
50 | in the Software without restriction, including without limitation the rights
51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52 | copies of the Software, and to permit persons to whom the Software is
53 | furnished to do so, subject to the following conditions:
54 |
55 | The above copyright notice and this permission notice shall be included in
56 | all copies or substantial portions of the Software.
57 |
58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
64 | THE SOFTWARE.
65 | License
66 | MIT
67 | Title
68 | Masonry
69 | Type
70 | PSGroupSpecifier
71 |
72 |
73 | FooterText
74 | Generated by CocoaPods - https://cocoapods.org
75 | Title
76 |
77 | Type
78 | PSGroupSpecifier
79 |
80 |
81 | StringsTable
82 | Acknowledgements
83 | Title
84 | Acknowledgements
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_LightDemo : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_LightDemo
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | set -u
4 | set -o pipefail
5 |
6 | if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
7 | # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
8 | # frameworks to, so exit 0 (signalling the script phase was successful).
9 | exit 0
10 | fi
11 |
12 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
13 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
14 |
15 | COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
16 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
17 |
18 | # Used as a return value for each invocation of `strip_invalid_archs` function.
19 | STRIP_BINARY_RETVAL=0
20 |
21 | # This protects against multiple targets copying the same framework dependency at the same time. The solution
22 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
23 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
24 |
25 | # Copies and strips a vendored framework
26 | install_framework()
27 | {
28 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
29 | local source="${BUILT_PRODUCTS_DIR}/$1"
30 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
31 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
32 | elif [ -r "$1" ]; then
33 | local source="$1"
34 | fi
35 |
36 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
37 |
38 | if [ -L "${source}" ]; then
39 | echo "Symlinked..."
40 | source="$(readlink "${source}")"
41 | fi
42 |
43 | # Use filter instead of exclude so missing patterns don't throw errors.
44 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
45 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
46 |
47 | local basename
48 | basename="$(basename -s .framework "$1")"
49 | binary="${destination}/${basename}.framework/${basename}"
50 | if ! [ -r "$binary" ]; then
51 | binary="${destination}/${basename}"
52 | fi
53 |
54 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
55 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
56 | strip_invalid_archs "$binary"
57 | fi
58 |
59 | # Resign the code if required by the build settings to avoid unstable apps
60 | code_sign_if_enabled "${destination}/$(basename "$1")"
61 |
62 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
63 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
64 | local swift_runtime_libs
65 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
66 | for lib in $swift_runtime_libs; do
67 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
68 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
69 | code_sign_if_enabled "${destination}/${lib}"
70 | done
71 | fi
72 | }
73 |
74 | # Copies and strips a vendored dSYM
75 | install_dsym() {
76 | local source="$1"
77 | if [ -r "$source" ]; then
78 | # Copy the dSYM into a the targets temp dir.
79 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\""
80 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
81 |
82 | local basename
83 | basename="$(basename -s .framework.dSYM "$source")"
84 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}"
85 |
86 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
87 | if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then
88 | strip_invalid_archs "$binary"
89 | fi
90 |
91 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then
92 | # Move the stripped file into its final destination.
93 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\""
94 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
95 | else
96 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
97 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM"
98 | fi
99 | fi
100 | }
101 |
102 | # Signs a framework with the provided identity
103 | code_sign_if_enabled() {
104 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
105 | # Use the current code_sign_identitiy
106 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
107 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
108 |
109 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
110 | code_sign_cmd="$code_sign_cmd &"
111 | fi
112 | echo "$code_sign_cmd"
113 | eval "$code_sign_cmd"
114 | fi
115 | }
116 |
117 | # Strip invalid architectures
118 | strip_invalid_archs() {
119 | binary="$1"
120 | # Get architectures for current target binary
121 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
122 | # Intersect them with the architectures we are building for
123 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
124 | # If there are no archs supported by this binary then warn the user
125 | if [[ -z "$intersected_archs" ]]; then
126 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
127 | STRIP_BINARY_RETVAL=0
128 | return
129 | fi
130 | stripped=""
131 | for arch in $binary_archs; do
132 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then
133 | # Strip non-valid architectures in-place
134 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
135 | stripped="$stripped $arch"
136 | fi
137 | done
138 | if [[ "$stripped" ]]; then
139 | echo "Stripped $binary of architectures:$stripped"
140 | fi
141 | STRIP_BINARY_RETVAL=1
142 | }
143 |
144 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
145 | wait
146 | fi
147 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | set -u
4 | set -o pipefail
5 |
6 | if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
7 | # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
8 | # resources to, so exit 0 (signalling the script phase was successful).
9 | exit 0
10 | fi
11 |
12 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
13 |
14 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
15 | > "$RESOURCES_TO_COPY"
16 |
17 | XCASSET_FILES=()
18 |
19 | # This protects against multiple targets copying the same framework dependency at the same time. The solution
20 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
21 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
22 |
23 | case "${TARGETED_DEVICE_FAMILY:-}" in
24 | 1,2)
25 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
26 | ;;
27 | 1)
28 | TARGET_DEVICE_ARGS="--target-device iphone"
29 | ;;
30 | 2)
31 | TARGET_DEVICE_ARGS="--target-device ipad"
32 | ;;
33 | 3)
34 | TARGET_DEVICE_ARGS="--target-device tv"
35 | ;;
36 | 4)
37 | TARGET_DEVICE_ARGS="--target-device watch"
38 | ;;
39 | *)
40 | TARGET_DEVICE_ARGS="--target-device mac"
41 | ;;
42 | esac
43 |
44 | install_resource()
45 | {
46 | if [[ "$1" = /* ]] ; then
47 | RESOURCE_PATH="$1"
48 | else
49 | RESOURCE_PATH="${PODS_ROOT}/$1"
50 | fi
51 | if [[ ! -e "$RESOURCE_PATH" ]] ; then
52 | cat << EOM
53 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
54 | EOM
55 | exit 1
56 | fi
57 | case $RESOURCE_PATH in
58 | *.storyboard)
59 | 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}" || true
60 | 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}
61 | ;;
62 | *.xib)
63 | 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}" || true
64 | 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}
65 | ;;
66 | *.framework)
67 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
68 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
69 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
70 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
71 | ;;
72 | *.xcdatamodel)
73 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true
74 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
75 | ;;
76 | *.xcdatamodeld)
77 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true
78 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
79 | ;;
80 | *.xcmappingmodel)
81 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true
82 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
83 | ;;
84 | *.xcassets)
85 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
86 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
87 | ;;
88 | *)
89 | echo "$RESOURCE_PATH" || true
90 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
91 | ;;
92 | esac
93 | }
94 |
95 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
96 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
97 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
98 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
99 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
100 | fi
101 | rm -f "$RESOURCES_TO_COPY"
102 |
103 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
104 | then
105 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
106 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
107 | while read line; do
108 | if [[ $line != "${PODS_ROOT}*" ]]; then
109 | XCASSET_FILES+=("$line")
110 | fi
111 | done <<<"$OTHER_XCASSETS"
112 |
113 | if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
114 | 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}"
115 | else
116 | 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}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
117 | fi
118 | fi
119 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MJExtension" "${PODS_ROOT}/Headers/Public/Masonry"
3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry"
4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MJExtension" -isystem "${PODS_ROOT}/Headers/Public/Masonry"
5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MJExtension" -l"Masonry" -framework "Foundation" -framework "UIKit"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-LightDemo/Pods-LightDemo.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MJExtension" "${PODS_ROOT}/Headers/Public/Masonry"
3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/MJExtension" "${PODS_CONFIGURATION_BUILD_DIR}/Masonry"
4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MJExtension" -isystem "${PODS_ROOT}/Headers/Public/Masonry"
5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MJExtension" -l"Masonry" -framework "Foundation" -framework "UIKit"
6 | PODS_BUILD_DIR = ${BUILD_DIR}
7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
9 | PODS_ROOT = ${SRCROOT}/Pods
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LightDemo
2 | Smart home light sence
3 |
4 | 效果图:
5 | 
6 |
7 |
--------------------------------------------------------------------------------
/light.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cesaradu/LightDemo/7a5430afd245fe4199b554a5519dabcbbe833eeb/light.gif
--------------------------------------------------------------------------------