├── Animation_demo.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── rong.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── rong.xcuserdatad
│ └── xcschemes
│ ├── Animation_demo.xcscheme
│ └── xcschememanagement.plist
├── Animation_demo.xcworkspace
├── contents.xcworkspacedata
└── xcuserdata
│ └── rong.xcuserdatad
│ ├── UserInterfaceState.xcuserstate
│ └── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
├── Animation_demo
├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
├── 5.jpg
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── CALayerDrawViewController.h
├── CALayerDrawViewController.m
├── CALayerViewController.h
├── CALayerViewController.m
├── CoreAnimatiionViewController.h
├── CoreAnimatiionViewController.m
├── CoreAnimationCADisplayLinkViewController.h
├── CoreAnimationCADisplayLinkViewController.m
├── CoreAnimationGroupViewController.h
├── CoreAnimationGroupViewController.m
├── CoreAnimationTranformViewController.h
├── CoreAnimationTranformViewController.m
├── Header.h
├── Info.plist
├── NormalViewController.h
├── NormalViewController.m
├── PrefixHeader.pch
├── ViewController.h
├── ViewController.m
├── bg.png
├── fish0.png
├── fish1.png
├── fish2.png
├── fish3.png
├── fish4.png
├── fish5.png
├── fish6.png
├── fish7.png
├── fish8.png
├── fish9.png
├── img1.jpg
├── img2.png
└── main.m
├── Animation_demoTests
├── Animation_demoTests.m
└── Info.plist
├── Animation_demoUITests
├── Animation_demoUITests.m
└── Info.plist
├── Podfile
├── Podfile.lock
├── Pods
├── Headers
│ ├── Private
│ │ └── 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
│ │ └── 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
├── 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
│ │ └── rong.xcuserdatad
│ │ └── xcschemes
│ │ ├── Masonry.xcscheme
│ │ ├── Pods.xcscheme
│ │ └── xcschememanagement.plist
└── Target Support Files
│ ├── Masonry
│ ├── Masonry-dummy.m
│ ├── Masonry-prefix.pch
│ └── Masonry.xcconfig
│ └── Pods
│ ├── Pods-acknowledgements.markdown
│ ├── Pods-acknowledgements.plist
│ ├── Pods-dummy.m
│ ├── Pods-frameworks.sh
│ ├── Pods-resources.sh
│ ├── Pods.debug.xcconfig
│ └── Pods.release.xcconfig
├── README.md
└── animation.gif
/Animation_demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Animation_demo.xcodeproj/project.xcworkspace/xcuserdata/rong.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo.xcodeproj/project.xcworkspace/xcuserdata/rong.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Animation_demo.xcodeproj/xcuserdata/rong.xcuserdatad/xcschemes/Animation_demo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/Animation_demo.xcodeproj/xcuserdata/rong.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Animation_demo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E7F8452F1CC4E0A7007EF3D3
16 |
17 | primary
18 |
19 |
20 | E7F845481CC4E0A8007EF3D3
21 |
22 | primary
23 |
24 |
25 | E7F845531CC4E0A8007EF3D3
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Animation_demo.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Animation_demo.xcworkspace/xcuserdata/rong.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo.xcworkspace/xcuserdata/rong.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Animation_demo.xcworkspace/xcuserdata/rong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/Animation_demo/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/1.jpg
--------------------------------------------------------------------------------
/Animation_demo/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/2.jpg
--------------------------------------------------------------------------------
/Animation_demo/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/3.jpg
--------------------------------------------------------------------------------
/Animation_demo/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/4.jpg
--------------------------------------------------------------------------------
/Animation_demo/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/5.jpg
--------------------------------------------------------------------------------
/Animation_demo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. 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 |
--------------------------------------------------------------------------------
/Animation_demo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Animation_demo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/Animation_demo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Animation_demo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Animation_demo/CALayerDrawViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CALayerDrawViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CALayerDrawViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Animation_demo/CALayerDrawViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CALayerDrawViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CALayerDrawViewController.h"
10 |
11 | #define PHOTO_HEIGHT 150.0
12 |
13 | @interface CALayerDrawViewController ()
14 |
15 | @end
16 |
17 | @implementation CALayerDrawViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 | self.view.backgroundColor = [UIColor whiteColor];
23 |
24 | CALayer *layer = [[CALayer alloc] init];
25 | layer.delegate = self;
26 | layer.backgroundColor = [UIColor redColor].CGColor;
27 | layer.position = self.view.center;
28 | layer.cornerRadius = PHOTO_HEIGHT/2.0;
29 | layer.masksToBounds = YES;;
30 | // layer.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0);
31 | layer.bounds = CGRectMake(0, 0, PHOTO_HEIGHT, PHOTO_HEIGHT);
32 |
33 | // UIImage *image = [UIImage imageNamed:@"img1.jpg"];
34 | // [layer setContents:(id)image.CGImage];
35 | [self.view.layer addSublayer:layer];
36 |
37 |
38 | [layer setNeedsDisplay];
39 |
40 | }
41 |
42 | #pragma mark -
43 | - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
44 | CGContextSaveGState(ctx);
45 | CGContextScaleCTM(ctx, 1, -1);
46 | CGContextTranslateCTM(ctx, 0, -PHOTO_HEIGHT);
47 | UIImage *image = [UIImage imageNamed:@"img1.jpg"];
48 |
49 | CGContextDrawImage(ctx, CGRectMake(0, 0, PHOTO_HEIGHT, PHOTO_HEIGHT), image.CGImage);
50 | CGContextRestoreGState(ctx);
51 | }
52 |
53 | - (void)didReceiveMemoryWarning {
54 | [super didReceiveMemoryWarning];
55 | // Dispose of any resources that can be recreated.
56 | }
57 |
58 | - (void)viewDidAppear:(BOOL)animated{
59 | CALayer *layer = self.view.layer.sublayers[0];
60 | layer.delegate = nil;
61 | }
62 |
63 | - (void)dealloc{
64 | NSLog(@"self.view:%@",self.view);
65 | }
66 |
67 | /*
68 | #pragma mark - Navigation
69 |
70 | // In a storyboard-based application, you will often want to do a little preparation before navigation
71 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
72 | // Get the new view controller using [segue destinationViewController].
73 | // Pass the selected object to the new view controller.
74 | }
75 | */
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/Animation_demo/CALayerViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CALayerViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CALayerViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Animation_demo/CALayerViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CALayerViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CALayerViewController.h"
10 |
11 | #define WIDTH 50.0
12 |
13 | @interface CALayerViewController ()
14 |
15 | @end
16 |
17 | @implementation CALayerViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 |
23 | self.view.backgroundColor = [UIColor whiteColor];
24 |
25 | [self initLayer];
26 |
27 | UILabel *tip = [[UILabel alloc] init];
28 | tip.text = @"touch anywhere you want";
29 | [self.view addSubview:tip];
30 | [tip makeConstraints:^(MASConstraintMaker *make) {
31 | make.top.equalTo(self.view).offset(64);
32 | make.centerX.equalTo(self.view);
33 | }];
34 |
35 |
36 | }
37 |
38 | - (void)initLayer{
39 | CALayer *layer = [[CALayer alloc] init];
40 | layer.backgroundColor = [UIColor colorWithRed:0 green:146/255.0 blue:1.0 alpha:1.0].CGColor;
41 | layer.cornerRadius = WIDTH/2.0;
42 | layer.position = self.view.center;
43 | layer.bounds = CGRectMake(0, 0, WIDTH, WIDTH);
44 |
45 | layer.shadowColor = [UIColor grayColor].CGColor;
46 | layer.shadowOffset = CGSizeMake(5, 5);
47 | layer.shadowOpacity = .9;
48 |
49 | [self.view.layer addSublayer:layer];
50 |
51 | }
52 |
53 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
54 | UITouch *touch = [touches anyObject];
55 | CGPoint newPoint = [touch locationInView:self.view];
56 | CALayer *layer = self.view.layer.sublayers[0];
57 | CGFloat width = layer.bounds.size.width;
58 | if (width == WIDTH) {
59 | width = WIDTH *4;
60 | }else{
61 | width = WIDTH;
62 | }
63 | layer.bounds = CGRectMake(0, 0, width, width);
64 | layer.position = newPoint;
65 | layer.cornerRadius = width/2.0;
66 | }
67 |
68 | - (void)didReceiveMemoryWarning {
69 | [super didReceiveMemoryWarning];
70 | // Dispose of any resources that can be recreated.
71 | }
72 |
73 | /*
74 | #pragma mark - Navigation
75 |
76 | // In a storyboard-based application, you will often want to do a little preparation before navigation
77 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
78 | // Get the new view controller using [segue destinationViewController].
79 | // Pass the selected object to the new view controller.
80 | }
81 | */
82 |
83 | @end
84 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimatiionViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimatiionViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoreAnimatiionViewController : UIViewController
12 |
13 | - (instancetype)initWithAnimationType:(AnimationType)type;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimatiionViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimatiionViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/20.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CoreAnimatiionViewController.h"
10 |
11 | @interface CoreAnimatiionViewController ()
12 |
13 | @property (assign, nonatomic) AnimationType type;
14 | @property (strong, nonatomic) CALayer *layer;
15 |
16 | @end
17 |
18 | @implementation CoreAnimatiionViewController
19 |
20 | - (instancetype)initWithAnimationType:(AnimationType)type{
21 | self = [super init];
22 | if (self) {
23 | _type = type;
24 | }
25 | return self;
26 | }
27 |
28 | - (void)viewDidLoad {
29 | [super viewDidLoad];
30 | // Do any additional setup after loading the view.
31 | self.view.backgroundColor = [UIColor whiteColor];
32 |
33 | _layer = [[CALayer alloc] init];
34 | _layer.bounds = CGRectMake(0, 0, 20, 20);
35 | _layer.position = CGPointMake(20, 74);
36 |
37 | UIImage *image = [UIImage imageNamed:@"img2"];
38 | [_layer setContents:(id)image.CGImage];
39 |
40 | [self.view.layer addSublayer:_layer];
41 |
42 | if (_type == AnimationTypeCoreKeyframe) {
43 | [self keyframeAnimation];
44 | }
45 |
46 | }
47 |
48 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
49 | if (_type == AnimationTypeCoreBase) {
50 | UITouch *touch = [touches anyObject];
51 | CGPoint point = [touch locationInView:self.view];
52 | CAAnimation *animation = [_layer animationForKey:@"base_animation"];
53 | if (animation) {
54 | if (_layer.speed == 0) {
55 | [self animationResume];
56 | }else{
57 | [self animationPause];
58 | }
59 | }else{
60 | [self baseAnimation:point];
61 | [self rotationAnimation];
62 | }
63 | }
64 | }
65 |
66 | //位置变化
67 | - (CABasicAnimation *)baseAnimation:(CGPoint)point{
68 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
69 | animation.toValue = [NSValue valueWithCGPoint:point];
70 | animation.duration = 1.0;
71 | animation.delegate = self;
72 | [animation setValue:[NSValue valueWithCGPoint:point] forKey:@"base_animation_value"];
73 | [_layer addAnimation:animation forKey:@"base_animation"];
74 | return animation;
75 | }
76 |
77 | //旋转
78 | - (CABasicAnimation *)rotationAnimation{
79 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
80 | animation.toValue = [NSNumber numberWithFloat:M_PI_2*3];
81 | animation.duration = 1.0;
82 | animation.autoreverses = YES;
83 | [_layer addAnimation:animation forKey:@"rotation_animation"];
84 | return animation;
85 | }
86 |
87 |
88 | //开始
89 | - (void)animationResume{
90 | CFTimeInterval interval = [_layer convertTime:CACurrentMediaTime() fromLayer:nil];
91 | [_layer setTimeOffset:interval];
92 | _layer.speed = 0;
93 | }
94 |
95 | //暂停
96 | - (void)animationPause{
97 | CFTimeInterval beginTime = CACurrentMediaTime()-_layer.timeOffset;
98 | _layer.timeOffset = 0;
99 | _layer.beginTime = beginTime;
100 | _layer.speed = 1.0;
101 | }
102 |
103 | //关键帧动画-贝塞尔曲线
104 | - (CAKeyframeAnimation *)keyframeAnimation{
105 | CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
106 |
107 | CGMutablePathRef path = CGPathCreateMutable();
108 | CGPathMoveToPoint(path, NULL, _layer.position.x, _layer.position.y);
109 | CGPathAddCurveToPoint(path, NULL, 160, 280, -30, 300, 55, 400);
110 | keyframeAnimation.path = path;
111 | CGPathRelease(path);
112 |
113 | keyframeAnimation.duration = 5.0;
114 | keyframeAnimation.beginTime = CACurrentMediaTime()+1.0;
115 | keyframeAnimation.repeatCount = HUGE_VALF;
116 |
117 | [_layer addAnimation:keyframeAnimation forKey:@"keyframe_animation"];
118 | return keyframeAnimation;
119 | }
120 |
121 |
122 | ////关键帧动画-属性值
123 | //- (void)keyframeAnimation{
124 | // CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
125 | // NSValue *key1 = [NSValue valueWithCGPoint:_layer.position];
126 | // NSValue *key2=[NSValue valueWithCGPoint:CGPointMake(80, 220)];
127 | // NSValue *key3=[NSValue valueWithCGPoint:CGPointMake(45, 300)];
128 | // NSValue *key4=[NSValue valueWithCGPoint:CGPointMake(55, 400)];
129 | // NSArray *values = @[key1,key2,key3,key4];
130 | // keyframeAnimation.values = values;
131 | //
132 | // keyframeAnimation.duration = 5.0;
133 | // keyframeAnimation.beginTime = CACurrentMediaTime()+1.0;
134 | // keyframeAnimation.repeatCount = HUGE_VALF;
135 | //
136 | // [_layer addAnimation:keyframeAnimation forKey:@"keyframe_animation"];
137 | //}
138 |
139 | #pragma mark - delegate methods
140 | - (void)animationDidStart:(CAAnimation *)anim{
141 |
142 | }
143 |
144 | - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
145 | [CATransaction begin];
146 | [CATransaction setDisableActions:YES];
147 | _layer.position = [[anim valueForKey:@"base_animation_value"] CGPointValue];
148 | [CATransaction commit];
149 | [self animationPause];
150 | }
151 |
152 | - (void)didReceiveMemoryWarning {
153 | [super didReceiveMemoryWarning];
154 | // Dispose of any resources that can be recreated.
155 | }
156 |
157 | /*
158 | #pragma mark - Navigation
159 |
160 | // In a storyboard-based application, you will often want to do a little preparation before navigation
161 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
162 | // Get the new view controller using [segue destinationViewController].
163 | // Pass the selected object to the new view controller.
164 | }
165 | */
166 |
167 | @end
168 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationCADisplayLinkViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationCADisplayLinkViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoreAnimationCADisplayLinkViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationCADisplayLinkViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationCADisplayLinkViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CoreAnimationCADisplayLinkViewController.h"
10 |
11 | #define IMAGE_COUNT 10
12 |
13 | @interface CoreAnimationCADisplayLinkViewController ()
14 |
15 | @property (strong, nonatomic) CALayer *layer;
16 | @property (assign, nonatomic) NSInteger currentIndex;
17 | @property (strong, nonatomic) NSMutableArray *images;
18 |
19 | @end
20 |
21 | @implementation CoreAnimationCADisplayLinkViewController
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 | // Do any additional setup after loading the view.
26 | self.view.backgroundColor = [UIColor whiteColor];
27 |
28 | [self.view.layer setContents:(id)[UIImage imageNamed:@"bg"].CGImage];
29 |
30 | _layer = [[CALayer alloc] init];
31 | _layer.bounds = CGRectMake(0, 0, 89, 40);
32 | _layer.position = CGPointMake(190, 310);
33 | _layer.contents = [UIImage imageNamed:@"fish.0"];
34 | [self.view.layer addSublayer:_layer];
35 |
36 | _images = [NSMutableArray array];
37 | for (int index = 0; index < IMAGE_COUNT; index ++) {
38 | UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"fish%d",index]];
39 | [_images addObject:image];
40 | }
41 |
42 | CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(step)];
43 | [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
44 |
45 |
46 | }
47 |
48 | - (void)step
49 | {
50 | static int s = 0;
51 | if (++s%10 == 0) {
52 | if (_currentIndex == 9) {
53 | _currentIndex = 0;
54 | }else{
55 | _currentIndex++;
56 | UIImage *image = _images[_currentIndex];
57 | [_layer setContents:(id)image.CGImage];
58 | }
59 | }
60 | }
61 |
62 | - (void)didReceiveMemoryWarning {
63 | [super didReceiveMemoryWarning];
64 | // Dispose of any resources that can be recreated.
65 | }
66 |
67 | /*
68 | #pragma mark - Navigation
69 |
70 | // In a storyboard-based application, you will often want to do a little preparation before navigation
71 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
72 | // Get the new view controller using [segue destinationViewController].
73 | // Pass the selected object to the new view controller.
74 | }
75 | */
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationGroupViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationGroupViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoreAnimationGroupViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationGroupViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationGroupViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CoreAnimationGroupViewController.h"
10 |
11 | @interface CoreAnimationGroupViewController ()
12 |
13 | @property (strong, nonatomic) CALayer *layer;
14 |
15 |
16 | @end
17 |
18 | @implementation CoreAnimationGroupViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view.
23 |
24 | self.view.backgroundColor = [UIColor whiteColor];
25 |
26 | _layer = [[CALayer alloc] init];
27 | _layer.bounds = CGRectMake(0, 0, 20, 20);
28 | _layer.position = CGPointMake(20, 74);
29 |
30 | UIImage *image = [UIImage imageNamed:@"img2"];
31 | [_layer setContents:(id)image.CGImage];
32 |
33 | [self.view.layer addSublayer:_layer];
34 |
35 | [self groupAnimation];
36 |
37 | }
38 |
39 | //动画组
40 | - (void)groupAnimation{
41 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
42 | CABasicAnimation *basicAnimation = [self rotationAnimation];
43 | CAKeyframeAnimation *keyframeAnimation = [self keyframeAnimation];
44 | animationGroup.animations = @[basicAnimation,keyframeAnimation];
45 |
46 | animationGroup.delegate = self;
47 | animationGroup.duration = 5.0;
48 | animationGroup.beginTime = CACurrentMediaTime()+1.0;
49 | animationGroup.repeatCount = HUGE_VALF;
50 |
51 | [_layer addAnimation:animationGroup forKey:nil];
52 | }
53 |
54 | //旋转
55 | - (CABasicAnimation *)rotationAnimation{
56 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
57 | animation.toValue = [NSNumber numberWithFloat:M_PI_2*3];
58 | animation.duration = 1.0;
59 | animation.autoreverses = YES;
60 | [animation setValue:[NSNumber numberWithFloat:M_PI_2*3] forKey:@"base_animation_toValue"];
61 | return animation;
62 | }
63 |
64 | //关键帧动画-贝塞尔曲线
65 | - (CAKeyframeAnimation *)keyframeAnimation{
66 | CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
67 |
68 | CGPoint endPoint = CGPointMake(55, 400);
69 | CGMutablePathRef path = CGPathCreateMutable();
70 | CGPathMoveToPoint(path, NULL, _layer.position.x, _layer.position.y);
71 | CGPathAddCurveToPoint(path, NULL, 160, 280, -30, 300, endPoint.x, endPoint.y);
72 | keyframeAnimation.path = path;
73 | CGPathRelease(path);
74 |
75 | [keyframeAnimation setValue:[NSValue valueWithCGPoint:endPoint] forKey:@"keyframeAnimation_endPosition"];
76 |
77 | return keyframeAnimation;
78 | }
79 |
80 | #pragma mark - delegate methods
81 | - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
82 | CAAnimationGroup *animationGroup = (CAAnimationGroup *)anim;
83 | CABasicAnimation *basicAnimation = animationGroup.animations[0];
84 | CAKeyframeAnimation *keyframeAnimation = animationGroup.animations[1];
85 | CGFloat toValue = [[basicAnimation valueForKey:@"base_animation_toValue"] floatValue];
86 | CGPoint endPoint = [[keyframeAnimation valueForKey:@"keyframeAnimation_endPosition"] CGPointValue];
87 | [CATransaction begin];
88 | [CATransaction setDisableActions:YES];
89 | _layer.position = endPoint;
90 | _layer.transform = CATransform3DMakeRotation(toValue, 0, 0, 1);
91 | [CATransaction commit];
92 | }
93 |
94 |
95 |
96 |
97 | - (void)didReceiveMemoryWarning {
98 | [super didReceiveMemoryWarning];
99 | // Dispose of any resources that can be recreated.
100 | }
101 |
102 | /*
103 | #pragma mark - Navigation
104 |
105 | // In a storyboard-based application, you will often want to do a little preparation before navigation
106 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
107 | // Get the new view controller using [segue destinationViewController].
108 | // Pass the selected object to the new view controller.
109 | }
110 | */
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationTranformViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationTranformViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoreAnimationTranformViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Animation_demo/CoreAnimationTranformViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreAnimationTranformViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/21.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "CoreAnimationTranformViewController.h"
10 |
11 | #define IMAGE_COUNT 5
12 |
13 | @interface CoreAnimationTranformViewController ()
14 |
15 | @property (strong, nonatomic) UIImageView *imageView;
16 | @property (assign, nonatomic) NSInteger currentIndex;
17 |
18 | @end
19 |
20 | @implementation CoreAnimationTranformViewController
21 |
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 | // Do any additional setup after loading the view.
25 |
26 | self.view.backgroundColor = [UIColor whiteColor];
27 | _imageView = [[UIImageView alloc] init];
28 | [self.view addSubview:_imageView];
29 | [_imageView makeConstraints:^(MASConstraintMaker *make) {
30 | make.top.equalTo(self.view).offset(64);
31 | make.left.right.bottom.equalTo(self.view);
32 | }];
33 | _imageView.image = [UIImage imageNamed:@"1.jpg"];
34 | _currentIndex = 1;
35 |
36 | UISwipeGestureRecognizer *leftSwip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipImage:)];
37 | leftSwip.direction = UISwipeGestureRecognizerDirectionLeft;
38 | [self.view addGestureRecognizer:leftSwip];
39 |
40 | UISwipeGestureRecognizer *rightSwip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipImage:)];
41 | rightSwip.direction = UISwipeGestureRecognizerDirectionRight;
42 | [self.view addGestureRecognizer:rightSwip];
43 |
44 |
45 | }
46 |
47 | - (void)leftSwipImage:(UISwipeGestureRecognizer *)swip{
48 | [self transitionAnimation:YES];
49 | }
50 |
51 | - (void)rightSwipImage:(UISwipeGestureRecognizer *)swip{
52 | [self transitionAnimation:NO];
53 | }
54 |
55 | - (void)transitionAnimation:(BOOL)isNext{
56 | CATransition *transition = [[CATransition alloc] init];
57 | transition.type = @"cube";
58 |
59 | if (isNext) {
60 | transition.subtype = kCATransitionFromRight;
61 | }else{
62 | transition.subtype = kCATransitionFromLeft;
63 | }
64 |
65 | transition.duration = 1.0f;
66 | if ((_currentIndex == IMAGE_COUNT && isNext) || (!isNext && _currentIndex == 1))return;
67 | _imageView.image = [self getImage:isNext];
68 | [_imageView.layer addAnimation:transition forKey:@"transition_animation"];
69 | }
70 |
71 | - (UIImage *)getImage:(BOOL)isNext{
72 | if (isNext) {
73 | // _currentIndex = (_currentIndex+1)%IMAGE_COUNT;
74 | _currentIndex ++;
75 | NSLog(@"下一张:%ld",_currentIndex);
76 | }else{
77 | // _currentIndex = (_currentIndex-1+IMAGE_COUNT)%IMAGE_COUNT;
78 | _currentIndex --;
79 | NSLog(@"上一张:%ld",_currentIndex);
80 | }
81 | NSString *imgName = [NSString stringWithFormat:@"%ld.jpg",_currentIndex];
82 | UIImage *image = [UIImage imageNamed:imgName];
83 | return image;
84 | }
85 |
86 | - (void)didReceiveMemoryWarning {
87 | [super didReceiveMemoryWarning];
88 | // Dispose of any resources that can be recreated.
89 | }
90 |
91 | /*
92 | #pragma mark - Navigation
93 |
94 | // In a storyboard-based application, you will often want to do a little preparation before navigation
95 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
96 | // Get the new view controller using [segue destinationViewController].
97 | // Pass the selected object to the new view controller.
98 | }
99 | */
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/Animation_demo/Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Header.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/19.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #ifndef Header_h
10 | #define Header_h
11 |
12 | #endif /* Header_h */
13 |
--------------------------------------------------------------------------------
/Animation_demo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Animation_demo/NormalViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NormalViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/19.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NormalViewController : UIViewController
12 |
13 | - (instancetype)initWithAnimationType:(AnimationType)type;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Animation_demo/NormalViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NormalViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/19.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "NormalViewController.h"
10 |
11 | @interface NormalViewController ()
12 |
13 | @property (assign, nonatomic) AnimationType type;
14 | @property (assign, nonatomic) BOOL isSelect;
15 |
16 | @property (strong, nonatomic) UIView *animationView;
17 | @property (strong, nonatomic) UIButton *animationBtn;
18 | @property (strong, nonatomic) MASConstraint *startTopConstraint;
19 | @property (strong, nonatomic) MASConstraint *startLeftConstraint;
20 | @property (strong, nonatomic) MASConstraint *endBottomConstraint;
21 | @property (strong, nonatomic) MASConstraint *endRightConstraint;
22 |
23 | @end
24 |
25 | @implementation NormalViewController
26 |
27 | - (instancetype)initWithAnimationType:(AnimationType)type{
28 | self = [super init];
29 | if (self) {
30 | _type = type;
31 | }
32 | return self;
33 | }
34 |
35 | - (void)viewDidLoad {
36 | [super viewDidLoad];
37 | // Do any additional setup after loading the view.
38 | self.view.backgroundColor = [UIColor whiteColor];
39 | self.animationView = [[UIView alloc] init];
40 | self.animationView.backgroundColor = [UIColor redColor];
41 | [self.view addSubview:self.animationView];
42 | [self.animationView makeConstraints:^(MASConstraintMaker *make) {
43 | self.startTopConstraint = make.top.equalTo(self.view).offset(70);
44 | self.startLeftConstraint = make.left.equalTo(self.view).offset(30);
45 | make.width.height.equalTo(@80);
46 | }];
47 |
48 | self.animationBtn = [[UIButton alloc] init];
49 | [self.animationBtn setTitle:@"开始动画" forState:UIControlStateNormal];
50 | [self.animationBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
51 | [self.view addSubview:self.animationBtn];
52 | [self.animationBtn makeConstraints:^(MASConstraintMaker *make) {
53 | make.top.equalTo(self.view).offset(70);
54 | make.right.equalTo(self.view).offset(-30);
55 | }];
56 | [self.animationBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
57 |
58 | }
59 |
60 | #pragma mark - 翻转动画
61 | - (void)clickBtn:(UIButton *)btn
62 | {
63 | _isSelect = btn.selected;
64 |
65 | switch (_type) {
66 | case AnimationTypeNormal:
67 | {
68 | [self normalAnimation];
69 | break;}
70 | case AnimationTypeSpring:
71 | {
72 | [self springAnimation];
73 | break;}
74 | case AnimationTypeKeyframe:
75 | {
76 | [self keyframeAnimation];
77 | break;}
78 | case AnimationTransition:
79 | {
80 | [self transitionAnimation];
81 | break;}
82 | default:
83 | break;
84 | }
85 | }
86 |
87 | #pragma mark - 常规动画
88 | - (void)normalAnimation{
89 | [UIView animateWithDuration:1.0 animations:^{
90 | [self.animationView updateConstraints:^(MASConstraintMaker *make) {
91 | if (_isSelect) {
92 | self.startTopConstraint = make.top.equalTo(self.view).offset(70);
93 | self.startLeftConstraint = make.left.equalTo(self.view).offset(30);
94 | self.animationBtn.selected = NO;
95 | [self.endBottomConstraint uninstall];
96 | [self.endRightConstraint uninstall];
97 | }else{
98 | self.endBottomConstraint = make.bottom.equalTo(self.view).offset(-30);
99 | self.endRightConstraint = make.right.equalTo(self.view).offset(-30);
100 | self.animationBtn.selected = YES;
101 | [self.startTopConstraint uninstall];
102 | [self.startLeftConstraint uninstall];
103 | }
104 | }];
105 | [self.view layoutIfNeeded];
106 | } completion:^(BOOL finished) {
107 |
108 | }];
109 | }
110 |
111 | #pragma mark - 弹簧动画
112 | - (void)springAnimation{
113 | [UIView animateWithDuration:6.0 delay:0 usingSpringWithDamping:0.2 initialSpringVelocity:10 options:UIViewAnimationOptionCurveEaseInOut animations:^{
114 | [self.animationView updateConstraints:^(MASConstraintMaker *make) {
115 | if (_isSelect) {
116 | self.startTopConstraint = make.top.equalTo(self.view).offset(70);
117 | self.startLeftConstraint = make.left.equalTo(self.view).offset(30);
118 | make.width.height.equalTo(@80);
119 | self.animationBtn.selected = NO;
120 | [self.endBottomConstraint uninstall];
121 | [self.endRightConstraint uninstall];
122 | }else{
123 | self.endBottomConstraint = make.center.equalTo(self.view);
124 | make.width.height.equalTo(@200);
125 | self.animationBtn.selected = YES;
126 | [self.startTopConstraint uninstall];
127 | [self.startLeftConstraint uninstall];
128 | }
129 | }];
130 | [self.view layoutIfNeeded];
131 |
132 | } completion:^(BOOL finished) {
133 |
134 | }];
135 | }
136 |
137 | #pragma mark - 关键帧动画
138 | - (void)keyframeAnimation{
139 | [UIView animateKeyframesWithDuration:6.0 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
140 | [self.animationView updateConstraints:^(MASConstraintMaker *make) {
141 | if (_isSelect) {
142 | self.startTopConstraint = make.top.equalTo(self.view).offset(70);
143 | self.startLeftConstraint = make.left.equalTo(self.view).offset(30);
144 | self.animationBtn.selected = NO;
145 | [self.endBottomConstraint uninstall];
146 | [self.endRightConstraint uninstall];
147 | }else{
148 | self.endBottomConstraint = make.bottom.equalTo(self.view).offset(-30);
149 | self.endRightConstraint = make.right.equalTo(self.view).offset(-30);
150 | self.animationBtn.selected = YES;
151 | [self.startTopConstraint uninstall];
152 | [self.startLeftConstraint uninstall];
153 | }
154 | }];
155 | [self.view layoutIfNeeded];
156 |
157 | [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:1/3.0 animations:^{
158 | self.animationView.backgroundColor = [UIColor redColor];
159 | }];
160 |
161 | [UIView addKeyframeWithRelativeStartTime:1/3.0 relativeDuration:1/3.0 animations:^{
162 | self.animationView.backgroundColor = [UIColor yellowColor];
163 | }];
164 |
165 | [UIView addKeyframeWithRelativeStartTime:2/3.0 relativeDuration:1/3.0 animations:^{
166 | self.animationView.backgroundColor = [UIColor redColor];
167 | }];
168 |
169 | } completion:^(BOOL finished) {
170 |
171 | }];
172 | }
173 |
174 | #pragma mark - 转场动画
175 | - (void)transitionAnimation{
176 | [UIView transitionWithView:self.animationView duration:2.0 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
177 | [self.animationView updateConstraints:^(MASConstraintMaker *make) {
178 | if (_isSelect) {
179 | self.startTopConstraint = make.top.equalTo(self.view).offset(70);
180 | self.startLeftConstraint = make.left.equalTo(self.view).offset(30);
181 | make.width.height.equalTo(@80);
182 | self.animationBtn.selected = NO;
183 | [self.endBottomConstraint uninstall];
184 | [self.endRightConstraint uninstall];
185 | }else{
186 | self.endBottomConstraint = make.center.equalTo(self.view);
187 | make.width.height.equalTo(@200);
188 | self.animationBtn.selected = YES;
189 | [self.startTopConstraint uninstall];
190 | [self.startLeftConstraint uninstall];
191 | }
192 | }];
193 | [self.view layoutIfNeeded];
194 |
195 | } completion:^(BOOL finished) {
196 |
197 | }];
198 | }
199 |
200 |
201 |
202 | - (void)didReceiveMemoryWarning {
203 | [super didReceiveMemoryWarning];
204 | // Dispose of any resources that can be recreated.
205 | }
206 |
207 | /*
208 | #pragma mark - Navigation
209 |
210 | // In a storyboard-based application, you will often want to do a little preparation before navigation
211 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
212 | // Get the new view controller using [segue destinationViewController].
213 | // Pass the selected object to the new view controller.
214 | }
215 | */
216 |
217 | @end
218 |
--------------------------------------------------------------------------------
/Animation_demo/PrefixHeader.pch:
--------------------------------------------------------------------------------
1 | //
2 | // PrefixHeader.pch
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/19.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 | #define MAS_SHORTHAND
9 |
10 | #import
11 | #import "Masonry.h"
12 |
13 | #ifndef PrefixHeader_pch
14 | #define PrefixHeader_pch
15 |
16 |
17 | typedef NS_ENUM(NSInteger,AnimationType){
18 | AnimationTypeNormal, //UIview封装普通动画
19 | AnimationTypeSpring, //UIview封装弹簧动画
20 | AnimationTypeKeyframe, //UIview封装关键帧动画
21 | AnimationTransition, //UIview封装转场动画
22 | AnimationTypeCALayer, //CALayer动画
23 | AnimationTypeCALayerDraw, //CALayer绘图
24 | AnimationTypeCoreBase, //Core Animation 基础动画
25 | AnimationTypeCoreKeyframe, //Core Animation 关键帧动画
26 | AnimationTypeCoreGroup, //Core Animation 动画组
27 | AnimationTypeCoreTranform, //Core Animation 转场动画
28 | AnimationTypeCoreCADisplayLink //Core Animation 逐帧动画
29 | };
30 |
31 |
32 | // Include any system framework and library headers here that should be included in all compilation units.
33 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
34 |
35 | #endif /* PrefixHeader_pch */
36 |
--------------------------------------------------------------------------------
/Animation_demo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/Animation_demo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "NormalViewController.h"
11 | #import "CALayerViewController.h"
12 | #import "CALayerDrawViewController.h"
13 | #import "CoreAnimatiionViewController.h"
14 | #import "CoreAnimationGroupViewController.h"
15 | #import "CoreAnimationTranformViewController.h"
16 | #import "CoreAnimationCADisplayLinkViewController.h"
17 |
18 | @interface ViewController ()
19 |
20 | @property (strong, nonatomic) UITableView *tableView;
21 | @property (strong, nonatomic) NSArray *data;
22 | @property (strong, nonatomic) NSArray *controllers;
23 |
24 |
25 | @end
26 |
27 | @implementation ViewController
28 |
29 | - (void)viewDidLoad {
30 | [super viewDidLoad];
31 | // Do any additional setup after loading the view, typically from a nib.
32 |
33 | self.title = @"Masonry动画";
34 |
35 | self.tableView = [[UITableView alloc] init];
36 | self.tableView.delegate = self;
37 | self.tableView.dataSource = self;
38 | [self.view addSubview:self.tableView];
39 | [self.tableView makeConstraints:^(MASConstraintMaker *make) {
40 | make.top.equalTo(self.view);
41 | make.left.right.bottom.equalTo(self.view);
42 | }];
43 |
44 | self.data = @[@"一般动画",@"弹簧动画",@"关键帧动画",@"转场动画",@"CALayer动画",@"CALayer绘图",@"Core Animation基础动画",@"Core Animation关键帧动画",@"Core Animation动画组",@"Core Animation转场动画",@"Core Animation逐帧动画"];
45 | self.controllers = @[@(AnimationTypeNormal),@(AnimationTypeSpring),@(AnimationTypeKeyframe),@(AnimationTransition),@(AnimationTypeCALayer),@(AnimationTypeCALayerDraw),@(AnimationTypeCoreBase),@(AnimationTypeCoreKeyframe),@(AnimationTypeCoreGroup),@(AnimationTypeCoreTranform),@(AnimationTypeCoreCADisplayLink)];
46 |
47 | }
48 |
49 | #pragma mark - UITableViewDataSource
50 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
51 | return self.data.count;
52 | }
53 |
54 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
55 | static NSString *cellId = @"cell";
56 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
57 | if (!cell) {
58 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
59 | }
60 | cell.textLabel.text = self.data[indexPath.row];
61 | return cell;
62 | }
63 |
64 | #pragma mark - UITableViewDelegate
65 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
66 | AnimationType type = [self.controllers[indexPath.row] integerValue];
67 | UIViewController *vc;
68 | if (type == AnimationTypeCALayer) {
69 | CALayerViewController *calayerVC = [[CALayerViewController alloc] init];
70 | vc = calayerVC;
71 | }else if(type == AnimationTypeCALayerDraw){
72 | CALayerDrawViewController *calayerDrawVC = [[CALayerDrawViewController alloc] init];
73 | vc = calayerDrawVC;
74 | }else if(type == AnimationTypeCoreKeyframe || type == AnimationTypeCoreBase){
75 | CoreAnimatiionViewController *coreVC = [[CoreAnimatiionViewController alloc] initWithAnimationType:type];
76 | vc = coreVC;
77 |
78 | }else if(type == AnimationTypeCoreGroup){
79 | CoreAnimationGroupViewController *groupVC = [[CoreAnimationGroupViewController alloc] init];
80 | vc = groupVC;
81 | }else if(type == AnimationTypeCoreTranform){
82 | CoreAnimationTranformViewController *tranformVC = [[CoreAnimationTranformViewController alloc] init];
83 | vc = tranformVC;
84 | }else if(type == AnimationTypeCoreCADisplayLink){
85 | CoreAnimationCADisplayLinkViewController *cadisplayLinkVC = [[CoreAnimationCADisplayLinkViewController alloc] init];
86 | vc = cadisplayLinkVC;
87 | }else{
88 | NormalViewController *normalVC = [[NormalViewController alloc] initWithAnimationType:type];
89 | vc = normalVC;
90 | }
91 | [self.navigationController pushViewController:vc animated:YES];
92 | }
93 |
94 | - (void)didReceiveMemoryWarning {
95 | [super didReceiveMemoryWarning];
96 | // Dispose of any resources that can be recreated.
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/Animation_demo/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/bg.png
--------------------------------------------------------------------------------
/Animation_demo/fish0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish0.png
--------------------------------------------------------------------------------
/Animation_demo/fish1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish1.png
--------------------------------------------------------------------------------
/Animation_demo/fish2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish2.png
--------------------------------------------------------------------------------
/Animation_demo/fish3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish3.png
--------------------------------------------------------------------------------
/Animation_demo/fish4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish4.png
--------------------------------------------------------------------------------
/Animation_demo/fish5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish5.png
--------------------------------------------------------------------------------
/Animation_demo/fish6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish6.png
--------------------------------------------------------------------------------
/Animation_demo/fish7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish7.png
--------------------------------------------------------------------------------
/Animation_demo/fish8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish8.png
--------------------------------------------------------------------------------
/Animation_demo/fish9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/fish9.png
--------------------------------------------------------------------------------
/Animation_demo/img1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/img1.jpg
--------------------------------------------------------------------------------
/Animation_demo/img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/Animation_demo/img2.png
--------------------------------------------------------------------------------
/Animation_demo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Animation_demo
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. 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 |
--------------------------------------------------------------------------------
/Animation_demoTests/Animation_demoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // Animation_demoTests.m
3 | // Animation_demoTests
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Animation_demoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation Animation_demoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/Animation_demoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Animation_demoUITests/Animation_demoUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // Animation_demoUITests.m
3 | // Animation_demoUITests
4 | //
5 | // Created by rong on 16/4/18.
6 | // Copyright © 2016年 rong. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Animation_demoUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation Animation_demoUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Animation_demoUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios,'6.0'
2 |
3 | pod 'Masonry'
4 |
5 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Masonry (1.0.0)
3 |
4 | DEPENDENCIES:
5 | - Masonry
6 |
7 | SPEC CHECKSUMS:
8 | Masonry: b529bb169217897b6354d4b56b1fada6d475b13d
9 |
10 | COCOAPODS: 0.39.0
11 |
--------------------------------------------------------------------------------
/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/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/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Masonry (1.0.0)
3 |
4 | DEPENDENCIES:
5 | - Masonry
6 |
7 | SPEC CHECKSUMS:
8 | Masonry: b529bb169217897b6354d4b56b1fada6d475b13d
9 |
10 | COCOAPODS: 0.39.0
11 |
--------------------------------------------------------------------------------
/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)setOffset:(CGFloat)offset {
133 | for (MASConstraint *constraint in self.childConstraints) {
134 | constraint.offset = offset;
135 | }
136 | }
137 |
138 | - (void)setSizeOffset:(CGSize)sizeOffset {
139 | for (MASConstraint *constraint in self.childConstraints) {
140 | constraint.sizeOffset = sizeOffset;
141 | }
142 | }
143 |
144 | - (void)setCenterOffset:(CGPoint)centerOffset {
145 | for (MASConstraint *constraint in self.childConstraints) {
146 | constraint.centerOffset = centerOffset;
147 | }
148 | }
149 |
150 | #pragma mark - MASConstraint
151 |
152 | - (void)activate {
153 | for (MASConstraint *constraint in self.childConstraints) {
154 | [constraint activate];
155 | }
156 | }
157 |
158 | - (void)deactivate {
159 | for (MASConstraint *constraint in self.childConstraints) {
160 | [constraint deactivate];
161 | }
162 | }
163 |
164 | - (void)install {
165 | for (MASConstraint *constraint in self.childConstraints) {
166 | constraint.updateExisting = self.updateExisting;
167 | [constraint install];
168 | }
169 | }
170 |
171 | - (void)uninstall {
172 | for (MASConstraint *constraint in self.childConstraints) {
173 | [constraint uninstall];
174 | }
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/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/MASConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * Enables Constraints to be created with chainable syntax
13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint)
14 | * or a group of NSLayoutConstraints (MASComposisteConstraint)
15 | */
16 | @interface MASConstraint : NSObject
17 |
18 | // Chaining Support
19 |
20 | /**
21 | * Modifies the NSLayoutConstraint constant,
22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
24 | */
25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets;
26 |
27 | /**
28 | * Modifies the NSLayoutConstraint constant,
29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
31 | */
32 | - (MASConstraint * (^)(CGSize offset))sizeOffset;
33 |
34 | /**
35 | * Modifies the NSLayoutConstraint constant,
36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
38 | */
39 | - (MASConstraint * (^)(CGPoint offset))centerOffset;
40 |
41 | /**
42 | * Modifies the NSLayoutConstraint constant
43 | */
44 | - (MASConstraint * (^)(CGFloat offset))offset;
45 |
46 | /**
47 | * Modifies the NSLayoutConstraint constant based on a value type
48 | */
49 | - (MASConstraint * (^)(NSValue *value))valueOffset;
50 |
51 | /**
52 | * Sets the NSLayoutConstraint multiplier property
53 | */
54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
55 |
56 | /**
57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy
58 | */
59 | - (MASConstraint * (^)(CGFloat divider))dividedBy;
60 |
61 | /**
62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority
63 | */
64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority;
65 |
66 | /**
67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow
68 | */
69 | - (MASConstraint * (^)())priorityLow;
70 |
71 | /**
72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium
73 | */
74 | - (MASConstraint * (^)())priorityMedium;
75 |
76 | /**
77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh
78 | */
79 | - (MASConstraint * (^)())priorityHigh;
80 |
81 | /**
82 | * Sets the constraint relation to NSLayoutRelationEqual
83 | * returns a block which accepts one of the following:
84 | * MASViewAttribute, UIView, NSValue, NSArray
85 | * see readme for more details.
86 | */
87 | - (MASConstraint * (^)(id attr))equalTo;
88 |
89 | /**
90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual
91 | * returns a block which accepts one of the following:
92 | * MASViewAttribute, UIView, NSValue, NSArray
93 | * see readme for more details.
94 | */
95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo;
96 |
97 | /**
98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual
99 | * returns a block which accepts one of the following:
100 | * MASViewAttribute, UIView, NSValue, NSArray
101 | * see readme for more details.
102 | */
103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo;
104 |
105 | /**
106 | * Optional semantic property which has no effect but improves the readability of constraint
107 | */
108 | - (MASConstraint *)with;
109 |
110 | /**
111 | * Optional semantic property which has no effect but improves the readability of constraint
112 | */
113 | - (MASConstraint *)and;
114 |
115 | /**
116 | * Creates a new MASCompositeConstraint with the called attribute and reciever
117 | */
118 | - (MASConstraint *)left;
119 | - (MASConstraint *)top;
120 | - (MASConstraint *)right;
121 | - (MASConstraint *)bottom;
122 | - (MASConstraint *)leading;
123 | - (MASConstraint *)trailing;
124 | - (MASConstraint *)width;
125 | - (MASConstraint *)height;
126 | - (MASConstraint *)centerX;
127 | - (MASConstraint *)centerY;
128 | - (MASConstraint *)baseline;
129 |
130 | #if TARGET_OS_IPHONE || TARGET_OS_TV
131 |
132 | - (MASConstraint *)leftMargin;
133 | - (MASConstraint *)rightMargin;
134 | - (MASConstraint *)topMargin;
135 | - (MASConstraint *)bottomMargin;
136 | - (MASConstraint *)leadingMargin;
137 | - (MASConstraint *)trailingMargin;
138 | - (MASConstraint *)centerXWithinMargins;
139 | - (MASConstraint *)centerYWithinMargins;
140 |
141 | #endif
142 |
143 |
144 | /**
145 | * Sets the constraint debug name
146 | */
147 | - (MASConstraint * (^)(id key))key;
148 |
149 | // NSLayoutConstraint constant Setters
150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks
151 |
152 | /**
153 | * Modifies the NSLayoutConstraint constant,
154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
156 | */
157 | - (void)setInsets:(MASEdgeInsets)insets;
158 |
159 | /**
160 | * Modifies the NSLayoutConstraint constant,
161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight
163 | */
164 | - (void)setSizeOffset:(CGSize)sizeOffset;
165 |
166 | /**
167 | * Modifies the NSLayoutConstraint constant,
168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
170 | */
171 | - (void)setCenterOffset:(CGPoint)centerOffset;
172 |
173 | /**
174 | * Modifies the NSLayoutConstraint constant
175 | */
176 | - (void)setOffset:(CGFloat)offset;
177 |
178 |
179 | // NSLayoutConstraint Installation support
180 |
181 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
182 | /**
183 | * Whether or not to go through the animator proxy when modifying the constraint
184 | */
185 | @property (nonatomic, copy, readonly) MASConstraint *animator;
186 | #endif
187 |
188 | /**
189 | * Activates an NSLayoutConstraint if it's supported by an OS.
190 | * Invokes install otherwise.
191 | */
192 | - (void)activate;
193 |
194 | /**
195 | * Deactivates previously installed/activated NSLayoutConstraint.
196 | */
197 | - (void)deactivate;
198 |
199 | /**
200 | * Creates a NSLayoutConstraint and adds it to the appropriate view.
201 | */
202 | - (void)install;
203 |
204 | /**
205 | * Removes previously installed NSLayoutConstraint
206 | */
207 | - (void)uninstall;
208 |
209 | @end
210 |
211 |
212 | /**
213 | * Convenience auto-boxing macros for MASConstraint methods.
214 | *
215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
216 | * A potential drawback of this is that the unprefixed macros will appear in global scope.
217 | */
218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__)))
219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
221 |
222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__)))
223 |
224 |
225 | #ifdef MAS_SHORTHAND_GLOBALS
226 |
227 | #define equalTo(...) mas_equalTo(__VA_ARGS__)
228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__)
229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__)
230 |
231 | #define offset(...) mas_offset(__VA_ARGS__)
232 |
233 | #endif
234 |
235 |
236 | @interface MASConstraint (AutoboxingSupport)
237 |
238 | /**
239 | * Aliases to corresponding relation methods (for shorthand macros)
240 | * Also needed to aid autocompletion
241 | */
242 | - (MASConstraint * (^)(id attr))mas_equalTo;
243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo;
244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo;
245 |
246 | /**
247 | * A dummy method to aid autocompletion
248 | */
249 | - (MASConstraint * (^)(id offset))mas_offset;
250 |
251 | @end
252 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.m
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 1/20/14.
6 | //
7 |
8 | #import "MASConstraint.h"
9 | #import "MASConstraint+Private.h"
10 |
11 | #define MASMethodNotImplemented() \
12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \
13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \
14 | userInfo:nil]
15 |
16 | @implementation MASConstraint
17 |
18 | #pragma mark - Init
19 |
20 | - (id)init {
21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly.");
22 | return [super init];
23 | }
24 |
25 | #pragma mark - NSLayoutRelation proxies
26 |
27 | - (MASConstraint * (^)(id))equalTo {
28 | return ^id(id attribute) {
29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
30 | };
31 | }
32 |
33 | - (MASConstraint * (^)(id))mas_equalTo {
34 | return ^id(id attribute) {
35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
36 | };
37 | }
38 |
39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo {
40 | return ^id(id attribute) {
41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
42 | };
43 | }
44 |
45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo {
46 | return ^id(id attribute) {
47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
48 | };
49 | }
50 |
51 | - (MASConstraint * (^)(id))lessThanOrEqualTo {
52 | return ^id(id attribute) {
53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
54 | };
55 | }
56 |
57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo {
58 | return ^id(id attribute) {
59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
60 | };
61 | }
62 |
63 | #pragma mark - MASLayoutPriority proxies
64 |
65 | - (MASConstraint * (^)())priorityLow {
66 | return ^id{
67 | self.priority(MASLayoutPriorityDefaultLow);
68 | return self;
69 | };
70 | }
71 |
72 | - (MASConstraint * (^)())priorityMedium {
73 | return ^id{
74 | self.priority(MASLayoutPriorityDefaultMedium);
75 | return self;
76 | };
77 | }
78 |
79 | - (MASConstraint * (^)())priorityHigh {
80 | return ^id{
81 | self.priority(MASLayoutPriorityDefaultHigh);
82 | return self;
83 | };
84 | }
85 |
86 | #pragma mark - NSLayoutConstraint constant proxies
87 |
88 | - (MASConstraint * (^)(MASEdgeInsets))insets {
89 | return ^id(MASEdgeInsets insets){
90 | self.insets = insets;
91 | return self;
92 | };
93 | }
94 |
95 | - (MASConstraint * (^)(CGSize))sizeOffset {
96 | return ^id(CGSize offset) {
97 | self.sizeOffset = offset;
98 | return self;
99 | };
100 | }
101 |
102 | - (MASConstraint * (^)(CGPoint))centerOffset {
103 | return ^id(CGPoint offset) {
104 | self.centerOffset = offset;
105 | return self;
106 | };
107 | }
108 |
109 | - (MASConstraint * (^)(CGFloat))offset {
110 | return ^id(CGFloat offset){
111 | self.offset = offset;
112 | return self;
113 | };
114 | }
115 |
116 | - (MASConstraint * (^)(NSValue *value))valueOffset {
117 | return ^id(NSValue *offset) {
118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
119 | [self setLayoutConstantWithValue:offset];
120 | return self;
121 | };
122 | }
123 |
124 | - (MASConstraint * (^)(id offset))mas_offset {
125 | // Will never be called due to macro
126 | return nil;
127 | }
128 |
129 | #pragma mark - NSLayoutConstraint constant setter
130 |
131 | - (void)setLayoutConstantWithValue:(NSValue *)value {
132 | if ([value isKindOfClass:NSNumber.class]) {
133 | self.offset = [(NSNumber *)value doubleValue];
134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) {
135 | CGPoint point;
136 | [value getValue:&point];
137 | self.centerOffset = point;
138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) {
139 | CGSize size;
140 | [value getValue:&size];
141 | self.sizeOffset = size;
142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) {
143 | MASEdgeInsets insets;
144 | [value getValue:&insets];
145 | self.insets = insets;
146 | } else {
147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value);
148 | }
149 | }
150 |
151 | #pragma mark - Semantic properties
152 |
153 | - (MASConstraint *)with {
154 | return self;
155 | }
156 |
157 | - (MASConstraint *)and {
158 | return self;
159 | }
160 |
161 | #pragma mark - Chaining
162 |
163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute {
164 | MASMethodNotImplemented();
165 | }
166 |
167 | - (MASConstraint *)left {
168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
169 | }
170 |
171 | - (MASConstraint *)top {
172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
173 | }
174 |
175 | - (MASConstraint *)right {
176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
177 | }
178 |
179 | - (MASConstraint *)bottom {
180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
181 | }
182 |
183 | - (MASConstraint *)leading {
184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
185 | }
186 |
187 | - (MASConstraint *)trailing {
188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
189 | }
190 |
191 | - (MASConstraint *)width {
192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
193 | }
194 |
195 | - (MASConstraint *)height {
196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
197 | }
198 |
199 | - (MASConstraint *)centerX {
200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
201 | }
202 |
203 | - (MASConstraint *)centerY {
204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
205 | }
206 |
207 | - (MASConstraint *)baseline {
208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
209 | }
210 |
211 | #if TARGET_OS_IPHONE || TARGET_OS_TV
212 |
213 | - (MASConstraint *)leftMargin {
214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
215 | }
216 |
217 | - (MASConstraint *)rightMargin {
218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
219 | }
220 |
221 | - (MASConstraint *)topMargin {
222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
223 | }
224 |
225 | - (MASConstraint *)bottomMargin {
226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
227 | }
228 |
229 | - (MASConstraint *)leadingMargin {
230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
231 | }
232 |
233 | - (MASConstraint *)trailingMargin {
234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
235 | }
236 |
237 | - (MASConstraint *)centerXWithinMargins {
238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
239 | }
240 |
241 | - (MASConstraint *)centerYWithinMargins {
242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
243 | }
244 |
245 | #endif
246 |
247 | #pragma mark - Abstract
248 |
249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); }
250 |
251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); }
252 |
253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); }
254 |
255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); }
256 |
257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); }
258 |
259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); }
260 |
261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); }
262 |
263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); }
264 |
265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); }
266 |
267 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
268 |
269 | - (MASConstraint *)animator { MASMethodNotImplemented(); }
270 |
271 | #endif
272 |
273 | - (void)activate { MASMethodNotImplemented(); }
274 |
275 | - (void)deactivate { MASMethodNotImplemented(); }
276 |
277 | - (void)install { MASMethodNotImplemented(); }
278 |
279 | - (void)uninstall { MASMethodNotImplemented(); }
280 |
281 | @end
282 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | typedef NS_OPTIONS(NSInteger, MASAttribute) {
13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft,
14 | MASAttributeRight = 1 << NSLayoutAttributeRight,
15 | MASAttributeTop = 1 << NSLayoutAttributeTop,
16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom,
17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading,
18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth,
20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight,
21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24 |
25 | #if TARGET_OS_IPHONE || TARGET_OS_TV
26 |
27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin,
29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin,
30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin,
31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,
35 |
36 | #endif
37 |
38 | };
39 |
40 | /**
41 | * Provides factory methods for creating MASConstraints.
42 | * Constraints are collected until they are ready to be installed
43 | *
44 | */
45 | @interface MASConstraintMaker : NSObject
46 |
47 | /**
48 | * The following properties return a new MASViewConstraint
49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute
50 | */
51 | @property (nonatomic, strong, readonly) MASConstraint *left;
52 | @property (nonatomic, strong, readonly) MASConstraint *top;
53 | @property (nonatomic, strong, readonly) MASConstraint *right;
54 | @property (nonatomic, strong, readonly) MASConstraint *bottom;
55 | @property (nonatomic, strong, readonly) MASConstraint *leading;
56 | @property (nonatomic, strong, readonly) MASConstraint *trailing;
57 | @property (nonatomic, strong, readonly) MASConstraint *width;
58 | @property (nonatomic, strong, readonly) MASConstraint *height;
59 | @property (nonatomic, strong, readonly) MASConstraint *centerX;
60 | @property (nonatomic, strong, readonly) MASConstraint *centerY;
61 | @property (nonatomic, strong, readonly) MASConstraint *baseline;
62 |
63 | #if TARGET_OS_IPHONE || TARGET_OS_TV
64 |
65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin;
66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin;
67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin;
68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin;
69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin;
70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin;
71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins;
72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins;
73 |
74 | #endif
75 |
76 | /**
77 | * Returns a block which creates a new MASCompositeConstraint with the first item set
78 | * to the makers associated view and children corresponding to the set bits in the
79 | * MASAttribute parameter. Combine multiple attributes via binary-or.
80 | */
81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs);
82 |
83 | /**
84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges
85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right)
86 | * with the first item set to the makers associated view
87 | */
88 | @property (nonatomic, strong, readonly) MASConstraint *edges;
89 |
90 | /**
91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize
92 | * which generates the appropriate MASViewConstraint children (width, height)
93 | * with the first item set to the makers associated view
94 | */
95 | @property (nonatomic, strong, readonly) MASConstraint *size;
96 |
97 | /**
98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter
99 | * which generates the appropriate MASViewConstraint children (centerX, centerY)
100 | * with the first item set to the makers associated view
101 | */
102 | @property (nonatomic, strong, readonly) MASConstraint *center;
103 |
104 | /**
105 | * Whether or not to check for an existing constraint instead of adding constraint
106 | */
107 | @property (nonatomic, assign) BOOL updateExisting;
108 |
109 | /**
110 | * Whether or not to remove existing constraints prior to installing
111 | */
112 | @property (nonatomic, assign) BOOL removeExisting;
113 |
114 | /**
115 | * initialises the maker with a default view
116 | *
117 | * @param view any MASConstrait are created with this view as the first item
118 | *
119 | * @return a new MASConstraintMaker
120 | */
121 | - (id)initWithView:(MAS_VIEW *)view;
122 |
123 | /**
124 | * Calls install method on any MASConstraints which have been created by this maker
125 | *
126 | * @return an array of all the installed MASConstraints
127 | */
128 | - (NSArray *)install;
129 |
130 | - (MASConstraint * (^)(dispatch_block_t))group;
131 |
132 | @end
133 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASConstraintMaker.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraintMaker.h"
10 | #import "MASViewConstraint.h"
11 | #import "MASCompositeConstraint.h"
12 | #import "MASConstraint+Private.h"
13 | #import "MASViewAttribute.h"
14 | #import "View+MASAdditions.h"
15 |
16 | @interface MASConstraintMaker ()
17 |
18 | @property (nonatomic, weak) MAS_VIEW *view;
19 | @property (nonatomic, strong) NSMutableArray *constraints;
20 |
21 | @end
22 |
23 | @implementation MASConstraintMaker
24 |
25 | - (id)initWithView:(MAS_VIEW *)view {
26 | self = [super init];
27 | if (!self) return nil;
28 |
29 | self.view = view;
30 | self.constraints = NSMutableArray.new;
31 |
32 | return self;
33 | }
34 |
35 | - (NSArray *)install {
36 | if (self.removeExisting) {
37 | NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view];
38 | for (MASConstraint *constraint in installedConstraints) {
39 | [constraint uninstall];
40 | }
41 | }
42 | NSArray *constraints = self.constraints.copy;
43 | for (MASConstraint *constraint in constraints) {
44 | constraint.updateExisting = self.updateExisting;
45 | [constraint install];
46 | }
47 | [self.constraints removeAllObjects];
48 | return constraints;
49 | }
50 |
51 | #pragma mark - MASConstraintDelegate
52 |
53 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
54 | NSUInteger index = [self.constraints indexOfObject:constraint];
55 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
56 | [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint];
57 | }
58 |
59 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
60 | MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute];
61 | MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute];
62 | if ([constraint isKindOfClass:MASViewConstraint.class]) {
63 | //replace with composite constraint
64 | NSArray *children = @[constraint, newConstraint];
65 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
66 | compositeConstraint.delegate = self;
67 | [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint];
68 | return compositeConstraint;
69 | }
70 | if (!constraint) {
71 | newConstraint.delegate = self;
72 | [self.constraints addObject:newConstraint];
73 | }
74 | return newConstraint;
75 | }
76 |
77 | - (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
78 | __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading
79 | | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX
80 | | MASAttributeCenterY | MASAttributeBaseline
81 | #if TARGET_OS_IPHONE || TARGET_OS_TV
82 | | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin
83 | | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins
84 | | MASAttributeCenterYWithinMargins
85 | #endif
86 | );
87 |
88 | NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)");
89 |
90 | NSMutableArray *attributes = [NSMutableArray array];
91 |
92 | if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left];
93 | if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right];
94 | if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top];
95 | if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom];
96 | if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading];
97 | if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing];
98 | if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width];
99 | if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height];
100 | if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX];
101 | if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY];
102 | if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline];
103 |
104 | #if TARGET_OS_IPHONE || TARGET_OS_TV
105 |
106 | if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin];
107 | if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin];
108 | if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin];
109 | if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin];
110 | if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin];
111 | if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin];
112 | if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins];
113 | if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins];
114 |
115 | #endif
116 |
117 | NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count];
118 |
119 | for (MASViewAttribute *a in attributes) {
120 | [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]];
121 | }
122 |
123 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
124 | constraint.delegate = self;
125 | [self.constraints addObject:constraint];
126 | return constraint;
127 | }
128 |
129 | #pragma mark - standard Attributes
130 |
131 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
132 | return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute];
133 | }
134 |
135 | - (MASConstraint *)left {
136 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
137 | }
138 |
139 | - (MASConstraint *)top {
140 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
141 | }
142 |
143 | - (MASConstraint *)right {
144 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
145 | }
146 |
147 | - (MASConstraint *)bottom {
148 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
149 | }
150 |
151 | - (MASConstraint *)leading {
152 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
153 | }
154 |
155 | - (MASConstraint *)trailing {
156 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
157 | }
158 |
159 | - (MASConstraint *)width {
160 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
161 | }
162 |
163 | - (MASConstraint *)height {
164 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
165 | }
166 |
167 | - (MASConstraint *)centerX {
168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
169 | }
170 |
171 | - (MASConstraint *)centerY {
172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
173 | }
174 |
175 | - (MASConstraint *)baseline {
176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
177 | }
178 |
179 | - (MASConstraint *(^)(MASAttribute))attributes {
180 | return ^(MASAttribute attrs){
181 | return [self addConstraintWithAttributes:attrs];
182 | };
183 | }
184 |
185 | #if TARGET_OS_IPHONE || TARGET_OS_TV
186 |
187 | - (MASConstraint *)leftMargin {
188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
189 | }
190 |
191 | - (MASConstraint *)rightMargin {
192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
193 | }
194 |
195 | - (MASConstraint *)topMargin {
196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
197 | }
198 |
199 | - (MASConstraint *)bottomMargin {
200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
201 | }
202 |
203 | - (MASConstraint *)leadingMargin {
204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
205 | }
206 |
207 | - (MASConstraint *)trailingMargin {
208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
209 | }
210 |
211 | - (MASConstraint *)centerXWithinMargins {
212 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
213 | }
214 |
215 | - (MASConstraint *)centerYWithinMargins {
216 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
217 | }
218 |
219 | #endif
220 |
221 |
222 | #pragma mark - composite Attributes
223 |
224 | - (MASConstraint *)edges {
225 | return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom];
226 | }
227 |
228 | - (MASConstraint *)size {
229 | return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight];
230 | }
231 |
232 | - (MASConstraint *)center {
233 | return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY];
234 | }
235 |
236 | #pragma mark - grouping
237 |
238 | - (MASConstraint *(^)(dispatch_block_t group))group {
239 | return ^id(dispatch_block_t group) {
240 | NSInteger previousCount = self.constraints.count;
241 | group();
242 |
243 | NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)];
244 | MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
245 | constraint.delegate = self;
246 | return constraint;
247 | };
248 | }
249 |
250 | @end
251 |
--------------------------------------------------------------------------------
/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 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/Pods/Masonry/Masonry/MASViewConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewConstraint.h"
10 | #import "MASConstraint+Private.h"
11 | #import "MASCompositeConstraint.h"
12 | #import "MASLayoutConstraint.h"
13 | #import "View+MASAdditions.h"
14 | #import
15 |
16 | @interface MAS_VIEW (MASConstraints)
17 |
18 | @property (nonatomic, readonly) NSMutableSet *mas_installedConstraints;
19 |
20 | @end
21 |
22 | @implementation MAS_VIEW (MASConstraints)
23 |
24 | static char kInstalledConstraintsKey;
25 |
26 | - (NSMutableSet *)mas_installedConstraints {
27 | NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey);
28 | if (!constraints) {
29 | constraints = [NSMutableSet set];
30 | objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
31 | }
32 | return constraints;
33 | }
34 |
35 | @end
36 |
37 |
38 | @interface MASViewConstraint ()
39 |
40 | @property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute;
41 | @property (nonatomic, weak) MAS_VIEW *installedView;
42 | @property (nonatomic, weak) MASLayoutConstraint *layoutConstraint;
43 | @property (nonatomic, assign) NSLayoutRelation layoutRelation;
44 | @property (nonatomic, assign) MASLayoutPriority layoutPriority;
45 | @property (nonatomic, assign) CGFloat layoutMultiplier;
46 | @property (nonatomic, assign) CGFloat layoutConstant;
47 | @property (nonatomic, assign) BOOL hasLayoutRelation;
48 | @property (nonatomic, strong) id mas_key;
49 | @property (nonatomic, assign) BOOL useAnimator;
50 |
51 | @end
52 |
53 | @implementation MASViewConstraint
54 |
55 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute {
56 | self = [super init];
57 | if (!self) return nil;
58 |
59 | _firstViewAttribute = firstViewAttribute;
60 | self.layoutPriority = MASLayoutPriorityRequired;
61 | self.layoutMultiplier = 1;
62 |
63 | return self;
64 | }
65 |
66 | #pragma mark - NSCoping
67 |
68 | - (id)copyWithZone:(NSZone __unused *)zone {
69 | MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute];
70 | constraint.layoutConstant = self.layoutConstant;
71 | constraint.layoutRelation = self.layoutRelation;
72 | constraint.layoutPriority = self.layoutPriority;
73 | constraint.layoutMultiplier = self.layoutMultiplier;
74 | constraint.delegate = self.delegate;
75 | return constraint;
76 | }
77 |
78 | #pragma mark - Public
79 |
80 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view {
81 | return [view.mas_installedConstraints allObjects];
82 | }
83 |
84 | #pragma mark - Private
85 |
86 | - (void)setLayoutConstant:(CGFloat)layoutConstant {
87 | _layoutConstant = layoutConstant;
88 |
89 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
90 | if (self.useAnimator) {
91 | [self.layoutConstraint.animator setConstant:layoutConstant];
92 | } else {
93 | self.layoutConstraint.constant = layoutConstant;
94 | }
95 | #else
96 | self.layoutConstraint.constant = layoutConstant;
97 | #endif
98 | }
99 |
100 | - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation {
101 | _layoutRelation = layoutRelation;
102 | self.hasLayoutRelation = YES;
103 | }
104 |
105 | - (BOOL)supportsActiveProperty {
106 | return [self.layoutConstraint respondsToSelector:@selector(isActive)];
107 | }
108 |
109 | - (BOOL)isActive {
110 | BOOL active = YES;
111 | if ([self supportsActiveProperty]) {
112 | active = [self.layoutConstraint isActive];
113 | }
114 |
115 | return active;
116 | }
117 |
118 | - (BOOL)hasBeenInstalled {
119 | return (self.layoutConstraint != nil) && [self isActive];
120 | }
121 |
122 | - (void)setSecondViewAttribute:(id)secondViewAttribute {
123 | if ([secondViewAttribute isKindOfClass:NSValue.class]) {
124 | [self setLayoutConstantWithValue:secondViewAttribute];
125 | } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {
126 | _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];
127 | } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
128 | _secondViewAttribute = secondViewAttribute;
129 | } else {
130 | NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
131 | }
132 | }
133 |
134 | #pragma mark - NSLayoutConstraint multiplier proxies
135 |
136 | - (MASConstraint * (^)(CGFloat))multipliedBy {
137 | return ^id(CGFloat multiplier) {
138 | NSAssert(!self.hasBeenInstalled,
139 | @"Cannot modify constraint multiplier after it has been installed");
140 |
141 | self.layoutMultiplier = multiplier;
142 | return self;
143 | };
144 | }
145 |
146 |
147 | - (MASConstraint * (^)(CGFloat))dividedBy {
148 | return ^id(CGFloat divider) {
149 | NSAssert(!self.hasBeenInstalled,
150 | @"Cannot modify constraint multiplier after it has been installed");
151 |
152 | self.layoutMultiplier = 1.0/divider;
153 | return self;
154 | };
155 | }
156 |
157 | #pragma mark - MASLayoutPriority proxy
158 |
159 | - (MASConstraint * (^)(MASLayoutPriority))priority {
160 | return ^id(MASLayoutPriority priority) {
161 | NSAssert(!self.hasBeenInstalled,
162 | @"Cannot modify constraint priority after it has been installed");
163 |
164 | self.layoutPriority = priority;
165 | return self;
166 | };
167 | }
168 |
169 | #pragma mark - NSLayoutRelation proxy
170 |
171 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
172 | return ^id(id attribute, NSLayoutRelation relation) {
173 | if ([attribute isKindOfClass:NSArray.class]) {
174 | NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation");
175 | NSMutableArray *children = NSMutableArray.new;
176 | for (id attr in attribute) {
177 | MASViewConstraint *viewConstraint = [self copy];
178 | viewConstraint.secondViewAttribute = attr;
179 | [children addObject:viewConstraint];
180 | }
181 | MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
182 | compositeConstraint.delegate = self.delegate;
183 | [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint];
184 | return compositeConstraint;
185 | } else {
186 | NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation");
187 | self.layoutRelation = relation;
188 | self.secondViewAttribute = attribute;
189 | return self;
190 | }
191 | };
192 | }
193 |
194 | #pragma mark - Semantic properties
195 |
196 | - (MASConstraint *)with {
197 | return self;
198 | }
199 |
200 | - (MASConstraint *)and {
201 | return self;
202 | }
203 |
204 | #pragma mark - attribute chaining
205 |
206 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
207 | NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation");
208 |
209 | return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
210 | }
211 |
212 | #pragma mark - Animator proxy
213 |
214 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
215 |
216 | - (MASConstraint *)animator {
217 | self.useAnimator = YES;
218 | return self;
219 | }
220 |
221 | #endif
222 |
223 | #pragma mark - debug helpers
224 |
225 | - (MASConstraint * (^)(id))key {
226 | return ^id(id key) {
227 | self.mas_key = key;
228 | return self;
229 | };
230 | }
231 |
232 | #pragma mark - NSLayoutConstraint constant setters
233 |
234 | - (void)setInsets:(MASEdgeInsets)insets {
235 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
236 | switch (layoutAttribute) {
237 | case NSLayoutAttributeLeft:
238 | case NSLayoutAttributeLeading:
239 | self.layoutConstant = insets.left;
240 | break;
241 | case NSLayoutAttributeTop:
242 | self.layoutConstant = insets.top;
243 | break;
244 | case NSLayoutAttributeBottom:
245 | self.layoutConstant = -insets.bottom;
246 | break;
247 | case NSLayoutAttributeRight:
248 | case NSLayoutAttributeTrailing:
249 | self.layoutConstant = -insets.right;
250 | break;
251 | default:
252 | break;
253 | }
254 | }
255 |
256 | - (void)setOffset:(CGFloat)offset {
257 | self.layoutConstant = offset;
258 | }
259 |
260 | - (void)setSizeOffset:(CGSize)sizeOffset {
261 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
262 | switch (layoutAttribute) {
263 | case NSLayoutAttributeWidth:
264 | self.layoutConstant = sizeOffset.width;
265 | break;
266 | case NSLayoutAttributeHeight:
267 | self.layoutConstant = sizeOffset.height;
268 | break;
269 | default:
270 | break;
271 | }
272 | }
273 |
274 | - (void)setCenterOffset:(CGPoint)centerOffset {
275 | NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
276 | switch (layoutAttribute) {
277 | case NSLayoutAttributeCenterX:
278 | self.layoutConstant = centerOffset.x;
279 | break;
280 | case NSLayoutAttributeCenterY:
281 | self.layoutConstant = centerOffset.y;
282 | break;
283 | default:
284 | break;
285 | }
286 | }
287 |
288 | #pragma mark - MASConstraint
289 |
290 | - (void)activate {
291 | [self install];
292 | }
293 |
294 | - (void)deactivate {
295 | [self uninstall];
296 | }
297 |
298 | - (void)install {
299 | if (self.hasBeenInstalled) {
300 | return;
301 | }
302 |
303 | if ([self supportsActiveProperty] && self.layoutConstraint) {
304 | self.layoutConstraint.active = YES;
305 | [self.firstViewAttribute.view.mas_installedConstraints addObject:self];
306 | return;
307 | }
308 |
309 | MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item;
310 | NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute;
311 | MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item;
312 | NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute;
313 |
314 | // alignment attributes must have a secondViewAttribute
315 | // therefore we assume that is refering to superview
316 | // eg make.left.equalTo(@10)
317 | if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) {
318 | secondLayoutItem = self.firstViewAttribute.view.superview;
319 | secondLayoutAttribute = firstLayoutAttribute;
320 | }
321 |
322 | MASLayoutConstraint *layoutConstraint
323 | = [MASLayoutConstraint constraintWithItem:firstLayoutItem
324 | attribute:firstLayoutAttribute
325 | relatedBy:self.layoutRelation
326 | toItem:secondLayoutItem
327 | attribute:secondLayoutAttribute
328 | multiplier:self.layoutMultiplier
329 | constant:self.layoutConstant];
330 |
331 | layoutConstraint.priority = self.layoutPriority;
332 | layoutConstraint.mas_key = self.mas_key;
333 |
334 | if (self.secondViewAttribute.view) {
335 | MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];
336 | NSAssert(closestCommonSuperview,
337 | @"couldn't find a common superview for %@ and %@",
338 | self.firstViewAttribute.view, self.secondViewAttribute.view);
339 | self.installedView = closestCommonSuperview;
340 | } else if (self.firstViewAttribute.isSizeAttribute) {
341 | self.installedView = self.firstViewAttribute.view;
342 | } else {
343 | self.installedView = self.firstViewAttribute.view.superview;
344 | }
345 |
346 |
347 | MASLayoutConstraint *existingConstraint = nil;
348 | if (self.updateExisting) {
349 | existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint];
350 | }
351 | if (existingConstraint) {
352 | // just update the constant
353 | existingConstraint.constant = layoutConstraint.constant;
354 | self.layoutConstraint = existingConstraint;
355 | } else {
356 | [self.installedView addConstraint:layoutConstraint];
357 | self.layoutConstraint = layoutConstraint;
358 | [firstLayoutItem.mas_installedConstraints addObject:self];
359 | }
360 | }
361 |
362 | - (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint {
363 | // check if any constraints are the same apart from the only mutable property constant
364 |
365 | // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints
366 | // and they are likely to be added first.
367 | for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) {
368 | if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue;
369 | if (existingConstraint.firstItem != layoutConstraint.firstItem) continue;
370 | if (existingConstraint.secondItem != layoutConstraint.secondItem) continue;
371 | if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue;
372 | if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue;
373 | if (existingConstraint.relation != layoutConstraint.relation) continue;
374 | if (existingConstraint.multiplier != layoutConstraint.multiplier) continue;
375 | if (existingConstraint.priority != layoutConstraint.priority) continue;
376 |
377 | return (id)existingConstraint;
378 | }
379 | return nil;
380 | }
381 |
382 | - (void)uninstall {
383 | if ([self supportsActiveProperty]) {
384 | self.layoutConstraint.active = NO;
385 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
386 | return;
387 | }
388 |
389 | [self.installedView removeConstraint:self.layoutConstraint];
390 | self.layoutConstraint = nil;
391 | self.installedView = nil;
392 |
393 | [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
394 | }
395 |
396 | @end
397 |
--------------------------------------------------------------------------------
/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 (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/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 == (CGFloat)self.count - 1) {//last one
57 | make.right.equalTo(tempSuperView).offset(-tailSpacing);
58 | }
59 | }
60 | else {//first one
61 | make.left.equalTo(tempSuperView).offset(leadSpacing);
62 | }
63 |
64 | }];
65 | prev = v;
66 | }
67 | }
68 | else {
69 | MAS_VIEW *prev;
70 | for (int i = 0; i < self.count; i++) {
71 | MAS_VIEW *v = self[i];
72 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
73 | if (prev) {
74 | make.height.equalTo(prev);
75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing);
76 | if (i == (CGFloat)self.count - 1) {//last one
77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
78 | }
79 | }
80 | else {//first one
81 | make.top.equalTo(tempSuperView).offset(leadSpacing);
82 | }
83 |
84 | }];
85 | prev = v;
86 | }
87 | }
88 | }
89 |
90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
91 | if (self.count < 2) {
92 | NSAssert(self.count>1,@"views to distribute need to bigger than one");
93 | return;
94 | }
95 |
96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
97 | if (axisType == MASAxisTypeHorizontal) {
98 | MAS_VIEW *prev;
99 | for (int i = 0; i < self.count; i++) {
100 | MAS_VIEW *v = self[i];
101 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
102 | if (prev) {
103 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
104 | make.width.equalTo(@(fixedItemLength));
105 | if (i == (CGFloat)self.count - 1) {//last one
106 | make.right.equalTo(tempSuperView).offset(-tailSpacing);
107 | }
108 | else {
109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
110 | }
111 | }
112 | else {//first one
113 | make.left.equalTo(tempSuperView).offset(leadSpacing);
114 | make.width.equalTo(@(fixedItemLength));
115 | }
116 | }];
117 | prev = v;
118 | }
119 | }
120 | else {
121 | MAS_VIEW *prev;
122 | for (int i = 0; i < self.count; i++) {
123 | MAS_VIEW *v = self[i];
124 | [v mas_makeConstraints:^(MASConstraintMaker *make) {
125 | if (prev) {
126 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
127 | make.height.equalTo(@(fixedItemLength));
128 | if (i == (CGFloat)self.count - 1) {//last one
129 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
130 | }
131 | else {
132 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
133 | }
134 | }
135 | else {//first one
136 | make.top.equalTo(tempSuperView).offset(leadSpacing);
137 | make.height.equalTo(@(fixedItemLength));
138 | }
139 | }];
140 | prev = v;
141 | }
142 | }
143 | }
144 |
145 | - (MAS_VIEW *)mas_commonSuperviewOfViews
146 | {
147 | MAS_VIEW *commonSuperview = nil;
148 | MAS_VIEW *previousView = nil;
149 | for (id object in self) {
150 | if ([object isKindOfClass:[MAS_VIEW class]]) {
151 | MAS_VIEW *view = (MAS_VIEW *)object;
152 | if (previousView) {
153 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview];
154 | } else {
155 | commonSuperview = view;
156 | }
157 | previousView = view;
158 | }
159 | }
160 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy.");
161 | return commonSuperview;
162 | }
163 |
164 | @end
165 |
--------------------------------------------------------------------------------
/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 TARGET_OS_IPHONE || TARGET_OS_TV
48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin",
49 | @(NSLayoutAttributeRightMargin) : @"rightMargin",
50 | @(NSLayoutAttributeTopMargin) : @"topMargin",
51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin",
52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin",
53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin",
54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins",
55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins",
56 | #endif
57 |
58 | };
59 |
60 | });
61 | return descriptionMap;
62 | }
63 |
64 |
65 | + (NSDictionary *)layoutPriorityDescriptionsByValue {
66 | static dispatch_once_t once;
67 | static NSDictionary *descriptionMap;
68 | dispatch_once(&once, ^{
69 | #if TARGET_OS_IPHONE || TARGET_OS_TV
70 | descriptionMap = @{
71 | @(MASLayoutPriorityDefaultHigh) : @"high",
72 | @(MASLayoutPriorityDefaultLow) : @"low",
73 | @(MASLayoutPriorityDefaultMedium) : @"medium",
74 | @(MASLayoutPriorityRequired) : @"required",
75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size",
76 | };
77 | #elif TARGET_OS_MAC
78 | descriptionMap = @{
79 | @(MASLayoutPriorityDefaultHigh) : @"high",
80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window",
81 | @(MASLayoutPriorityDefaultMedium) : @"medium",
82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put",
83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window",
84 | @(MASLayoutPriorityDefaultLow) : @"low",
85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size",
86 | @(MASLayoutPriorityRequired) : @"required",
87 | };
88 | #endif
89 | });
90 | return descriptionMap;
91 | }
92 |
93 | #pragma mark - description override
94 |
95 | + (NSString *)descriptionForObject:(id)obj {
96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) {
97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]];
98 | }
99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj];
100 | }
101 |
102 | - (NSString *)description {
103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"];
104 |
105 | [description appendString:[self.class descriptionForObject:self]];
106 |
107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
109 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
110 | }
111 |
112 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
113 |
114 | if (self.secondItem) {
115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
116 | }
117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
118 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
119 | }
120 |
121 | if (self.multiplier != 1) {
122 | [description appendFormat:@" * %g", self.multiplier];
123 | }
124 |
125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) {
126 | [description appendFormat:@" %g", self.constant];
127 | } else {
128 | if (self.constant) {
129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)];
130 | }
131 | }
132 |
133 | if (self.priority != MASLayoutPriorityRequired) {
134 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
135 | }
136 |
137 | [description appendString:@">"];
138 | return description;
139 | }
140 |
141 | @end
142 |
--------------------------------------------------------------------------------
/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 TARGET_OS_IPHONE || TARGET_OS_TV
36 |
37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
45 |
46 | #endif
47 |
48 | /**
49 | * a key to associate with this view
50 | */
51 | @property (nonatomic, strong) id mas_key;
52 |
53 | /**
54 | * Finds the closest common superview between this view and another view
55 | *
56 | * @param view other view
57 | *
58 | * @return returns nil if common superview could not be found
59 | */
60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
61 |
62 | /**
63 | * Creates a MASConstraintMaker with the callee view.
64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing
65 | *
66 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
67 | *
68 | * @return Array of created MASConstraints
69 | */
70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block;
71 |
72 | /**
73 | * Creates a MASConstraintMaker with the callee view.
74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
75 | * If an existing constraint exists then it will be updated instead.
76 | *
77 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
78 | *
79 | * @return Array of created/updated MASConstraints
80 | */
81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block;
82 |
83 | /**
84 | * Creates a MASConstraintMaker with the callee view.
85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
86 | * All constraints previously installed for the view will be removed.
87 | *
88 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
89 | *
90 | * @return Array of created/updated MASConstraints
91 | */
92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block;
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/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 TARGET_OS_IPHONE || TARGET_OS_TV
91 |
92 | - (MASViewAttribute *)mas_leftMargin {
93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin];
94 | }
95 |
96 | - (MASViewAttribute *)mas_rightMargin {
97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin];
98 | }
99 |
100 | - (MASViewAttribute *)mas_topMargin {
101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin];
102 | }
103 |
104 | - (MASViewAttribute *)mas_bottomMargin {
105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin];
106 | }
107 |
108 | - (MASViewAttribute *)mas_leadingMargin {
109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin];
110 | }
111 |
112 | - (MASViewAttribute *)mas_trailingMargin {
113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin];
114 | }
115 |
116 | - (MASViewAttribute *)mas_centerXWithinMargins {
117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins];
118 | }
119 |
120 | - (MASViewAttribute *)mas_centerYWithinMargins {
121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
122 | }
123 |
124 | #endif
125 |
126 | #pragma mark - associated properties
127 |
128 | - (id)mas_key {
129 | return objc_getAssociatedObject(self, @selector(mas_key));
130 | }
131 |
132 | - (void)setMas_key:(id)key {
133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
134 | }
135 |
136 | #pragma mark - heirachy
137 |
138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
139 | MAS_VIEW *closestCommonSuperview = nil;
140 |
141 | MAS_VIEW *secondViewSuperview = view;
142 | while (!closestCommonSuperview && secondViewSuperview) {
143 | MAS_VIEW *firstViewSuperview = self;
144 | while (!closestCommonSuperview && firstViewSuperview) {
145 | if (secondViewSuperview == firstViewSuperview) {
146 | closestCommonSuperview = secondViewSuperview;
147 | }
148 | firstViewSuperview = firstViewSuperview.superview;
149 | }
150 | secondViewSuperview = secondViewSuperview.superview;
151 | }
152 | return closestCommonSuperview;
153 | }
154 |
155 | @end
156 |
--------------------------------------------------------------------------------
/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 TARGET_OS_IPHONE || TARGET_OS_TV
33 |
34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin;
36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin;
37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin;
38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin;
39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin;
40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins;
41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins;
42 |
43 | #endif
44 |
45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
48 |
49 | @end
50 |
51 | #define MAS_ATTR_FORWARD(attr) \
52 | - (MASViewAttribute *)attr { \
53 | return [self mas_##attr]; \
54 | }
55 |
56 | @implementation MAS_VIEW (MASShorthandAdditions)
57 |
58 | MAS_ATTR_FORWARD(top);
59 | MAS_ATTR_FORWARD(left);
60 | MAS_ATTR_FORWARD(bottom);
61 | MAS_ATTR_FORWARD(right);
62 | MAS_ATTR_FORWARD(leading);
63 | MAS_ATTR_FORWARD(trailing);
64 | MAS_ATTR_FORWARD(width);
65 | MAS_ATTR_FORWARD(height);
66 | MAS_ATTR_FORWARD(centerX);
67 | MAS_ATTR_FORWARD(centerY);
68 | MAS_ATTR_FORWARD(baseline);
69 |
70 | #if TARGET_OS_IPHONE || TARGET_OS_TV
71 |
72 | MAS_ATTR_FORWARD(leftMargin);
73 | MAS_ATTR_FORWARD(rightMargin);
74 | MAS_ATTR_FORWARD(topMargin);
75 | MAS_ATTR_FORWARD(bottomMargin);
76 | MAS_ATTR_FORWARD(leadingMargin);
77 | MAS_ATTR_FORWARD(trailingMargin);
78 | MAS_ATTR_FORWARD(centerXWithinMargins);
79 | MAS_ATTR_FORWARD(centerYWithinMargins);
80 |
81 | #endif
82 |
83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
84 | return [self mas_attribute];
85 | }
86 |
87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
88 | return [self mas_makeConstraints:block];
89 | }
90 |
91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
92 | return [self mas_updateConstraints:block];
93 | }
94 |
95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
96 | return [self mas_remakeConstraints:block];
97 | }
98 |
99 | @end
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/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/Masonry/README.md:
--------------------------------------------------------------------------------
1 | #Masonry [](https://travis-ci.org/SnapKit/Masonry) [](https://coveralls.io/r/SnapKit/Masonry) [](https://github.com/Carthage/Carthage)
2 |
3 | **Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're using Swift in your project, we recommend using [SnapKit](https://github.com/SnapKit/SnapKit) as it provides better type safety with a simpler API.**
4 |
5 | Masonry is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Masonry has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable.
6 | Masonry supports iOS and Mac OS X.
7 |
8 | For examples take a look at the **Masonry iOS Examples** project in the Masonry workspace. You will need to run `pod install` after downloading.
9 |
10 | ## What's wrong with NSLayoutConstraints?
11 |
12 | Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive.
13 | Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side
14 | ```obj-c
15 | UIView *superview = self.view;
16 |
17 | UIView *view1 = [[UIView alloc] init];
18 | view1.translatesAutoresizingMaskIntoConstraints = NO;
19 | view1.backgroundColor = [UIColor greenColor];
20 | [superview addSubview:view1];
21 |
22 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
23 |
24 | [superview addConstraints:@[
25 |
26 | //view1 constraints
27 | [NSLayoutConstraint constraintWithItem:view1
28 | attribute:NSLayoutAttributeTop
29 | relatedBy:NSLayoutRelationEqual
30 | toItem:superview
31 | attribute:NSLayoutAttributeTop
32 | multiplier:1.0
33 | constant:padding.top],
34 |
35 | [NSLayoutConstraint constraintWithItem:view1
36 | attribute:NSLayoutAttributeLeft
37 | relatedBy:NSLayoutRelationEqual
38 | toItem:superview
39 | attribute:NSLayoutAttributeLeft
40 | multiplier:1.0
41 | constant:padding.left],
42 |
43 | [NSLayoutConstraint constraintWithItem:view1
44 | attribute:NSLayoutAttributeBottom
45 | relatedBy:NSLayoutRelationEqual
46 | toItem:superview
47 | attribute:NSLayoutAttributeBottom
48 | multiplier:1.0
49 | constant:-padding.bottom],
50 |
51 | [NSLayoutConstraint constraintWithItem:view1
52 | attribute:NSLayoutAttributeRight
53 | relatedBy:NSLayoutRelationEqual
54 | toItem:superview
55 | attribute:NSLayoutAttributeRight
56 | multiplier:1
57 | constant:-padding.right],
58 |
59 | ]];
60 | ```
61 | Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views.
62 | Another option is to use Visual Format Language (VFL), which is a bit less long winded.
63 | However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint constraintsWithVisualFormat:` returns an array.
64 |
65 | ## Prepare to meet your Maker!
66 |
67 | Heres the same constraints created using MASConstraintMaker
68 |
69 | ```obj-c
70 | UIEdgeInsets padding = UIEdgeInsetsMake(10, 10, 10, 10);
71 |
72 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
73 | make.top.equalTo(superview.mas_top).with.offset(padding.top); //with is an optional semantic filler
74 | make.left.equalTo(superview.mas_left).with.offset(padding.left);
75 | make.bottom.equalTo(superview.mas_bottom).with.offset(-padding.bottom);
76 | make.right.equalTo(superview.mas_right).with.offset(-padding.right);
77 | }];
78 | ```
79 | Or even shorter
80 |
81 | ```obj-c
82 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
83 | make.edges.equalTo(superview).with.insets(padding);
84 | }];
85 | ```
86 |
87 | Also note in the first example we had to add the constraints to the superview `[superview addConstraints:...`.
88 | Masonry however will automagically add constraints to the appropriate view.
89 |
90 | Masonry will also call `view1.translatesAutoresizingMaskIntoConstraints = NO;` for you.
91 |
92 | ## Not all things are created equal
93 |
94 | > `.equalTo` equivalent to **NSLayoutRelationEqual**
95 |
96 | > `.lessThanOrEqualTo` equivalent to **NSLayoutRelationLessThanOrEqual**
97 |
98 | > `.greaterThanOrEqualTo` equivalent to **NSLayoutRelationGreaterThanOrEqual**
99 |
100 | These three equality constraints accept one argument which can be any of the following:
101 |
102 | #### 1. MASViewAttribute
103 |
104 | ```obj-c
105 | make.centerX.lessThanOrEqualTo(view2.mas_left);
106 | ```
107 |
108 | MASViewAttribute | NSLayoutAttribute
109 | ------------------------- | --------------------------
110 | view.mas_left | NSLayoutAttributeLeft
111 | view.mas_right | NSLayoutAttributeRight
112 | view.mas_top | NSLayoutAttributeTop
113 | view.mas_bottom | NSLayoutAttributeBottom
114 | view.mas_leading | NSLayoutAttributeLeading
115 | view.mas_trailing | NSLayoutAttributeTrailing
116 | view.mas_width | NSLayoutAttributeWidth
117 | view.mas_height | NSLayoutAttributeHeight
118 | view.mas_centerX | NSLayoutAttributeCenterX
119 | view.mas_centerY | NSLayoutAttributeCenterY
120 | view.mas_baseline | NSLayoutAttributeBaseline
121 |
122 | #### 2. UIView/NSView
123 |
124 | if you want view.left to be greater than or equal to label.left :
125 | ```obj-c
126 | //these two constraints are exactly the same
127 | make.left.greaterThanOrEqualTo(label);
128 | make.left.greaterThanOrEqualTo(label.mas_left);
129 | ```
130 |
131 | #### 3. NSNumber
132 |
133 | Auto Layout allows width and height to be set to constant values.
134 | if you want to set view to have a minimum and maximum width you could pass a number to the equality blocks:
135 | ```obj-c
136 | //width >= 200 && width <= 400
137 | make.width.greaterThanOrEqualTo(@200);
138 | make.width.lessThanOrEqualTo(@400)
139 | ```
140 |
141 | However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values.
142 | So if you pass a NSNumber for these attributes Masonry will turn these into constraints relative to the view’s superview ie:
143 | ```obj-c
144 | //creates view.left = view.superview.left + 10
145 | make.left.lessThanOrEqualTo(@10)
146 | ```
147 |
148 | Instead of using NSNumber, you can use primitives and structs to build your constraints, like so:
149 | ```obj-c
150 | make.top.mas_equalTo(42);
151 | make.height.mas_equalTo(20);
152 | make.size.mas_equalTo(CGSizeMake(50, 100));
153 | make.edges.mas_equalTo(UIEdgeInsetsMake(10, 0, 10, 0));
154 | make.left.mas_equalTo(view).mas_offset(UIEdgeInsetsMake(10, 0, 10, 0));
155 | ```
156 |
157 | By default, macros which support [autoboxing](https://en.wikipedia.org/wiki/Autoboxing#Autoboxing) are prefixed with `mas_`. Unprefixed versions are available by defining `MAS_SHORTHAND_GLOBALS` before importing Masonry.
158 |
159 | #### 4. NSArray
160 |
161 | An array of a mixture of any of the previous types
162 | ```obj-c
163 | make.height.equalTo(@[view1.mas_height, view2.mas_height]);
164 | make.height.equalTo(@[view1, view2]);
165 | make.left.equalTo(@[view1, @100, view3.right]);
166 | ````
167 |
168 | ## Learn to prioritize
169 |
170 | > `.priority` allows you to specify an exact priority
171 |
172 | > `.priorityHigh` equivalent to **UILayoutPriorityDefaultHigh**
173 |
174 | > `.priorityMedium` is half way between high and low
175 |
176 | > `.priorityLow` equivalent to **UILayoutPriorityDefaultLow**
177 |
178 | Priorities are can be tacked on to the end of a constraint chain like so:
179 | ```obj-c
180 | make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow();
181 |
182 | make.top.equalTo(label.mas_top).with.priority(600);
183 | ```
184 |
185 | ## Composition, composition, composition
186 |
187 | Masonry also gives you a few convenience methods which create multiple constraints at the same time. These are called MASCompositeConstraints
188 |
189 | #### edges
190 |
191 | ```obj-c
192 | // make top, left, bottom, right equal view2
193 | make.edges.equalTo(view2);
194 |
195 | // make top = superview.top + 5, left = superview.left + 10,
196 | // bottom = superview.bottom - 15, right = superview.right - 20
197 | make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20))
198 | ```
199 |
200 | #### size
201 |
202 | ```obj-c
203 | // make width and height greater than or equal to titleLabel
204 | make.size.greaterThanOrEqualTo(titleLabel)
205 |
206 | // make width = superview.width + 100, height = superview.height - 50
207 | make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50))
208 | ```
209 |
210 | #### center
211 | ```obj-c
212 | // make centerX and centerY = button1
213 | make.center.equalTo(button1)
214 |
215 | // make centerX = superview.centerX - 5, centerY = superview.centerY + 10
216 | make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10))
217 | ```
218 |
219 | You can chain view attributes for increased readability:
220 |
221 | ```obj-c
222 | // All edges but the top should equal those of the superview
223 | make.left.right.and.bottom.equalTo(superview);
224 | make.top.equalTo(otherView);
225 | ```
226 |
227 | ## Hold on for dear life
228 |
229 | Sometimes you need modify existing constraints in order to animate or remove/replace constraints.
230 | In Masonry there are a few different approaches to updating constraints.
231 |
232 | #### 1. References
233 | You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property.
234 | You could also reference multiple constraints by storing them away in an array.
235 |
236 | ```obj-c
237 | // in public/private interface
238 | @property (nonatomic, strong) MASConstraint *topConstraint;
239 |
240 | ...
241 |
242 | // when making constraints
243 | [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
244 | self.topConstraint = make.top.equalTo(superview.mas_top).with.offset(padding.top);
245 | make.left.equalTo(superview.mas_left).with.offset(padding.left);
246 | }];
247 |
248 | ...
249 | // then later you can call
250 | [self.topConstraint uninstall];
251 | ```
252 |
253 | #### 2. mas_updateConstraints
254 | Alternatively if you are only updating the constant value of the constraint you can use the convience method `mas_updateConstraints` instead of `mas_makeConstraints`
255 |
256 | ```obj-c
257 | // this is Apple's recommended place for adding/updating constraints
258 | // this method can get called multiple times in response to setNeedsUpdateConstraints
259 | // which can be called by UIKit internally or in your code if you need to trigger an update to your constraints
260 | - (void)updateConstraints {
261 | [self.growingButton mas_updateConstraints:^(MASConstraintMaker *make) {
262 | make.center.equalTo(self);
263 | make.width.equalTo(@(self.buttonSize.width)).priorityLow();
264 | make.height.equalTo(@(self.buttonSize.height)).priorityLow();
265 | make.width.lessThanOrEqualTo(self);
266 | make.height.lessThanOrEqualTo(self);
267 | }];
268 |
269 | //according to apple super should be called at end of method
270 | [super updateConstraints];
271 | }
272 | ```
273 |
274 | ### 3. mas_remakeConstraints
275 | `mas_updateConstraints` is useful for updating a set of constraints, but doing anything beyond updating constant values can get exhausting. That's where `mas_remakeConstraints` comes in.
276 |
277 | `mas_remakeConstraints` is similar to `mas_updateConstraints`, but instead of updating constant values, it will remove all of its constraints before installing them again. This lets you provide different constraints without having to keep around references to ones which you want to remove.
278 |
279 | ```obj-c
280 | - (void)changeButtonPosition {
281 | [self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
282 | make.size.equalTo(self.buttonSize);
283 |
284 | if (topLeft) {
285 | make.top.and.left.offset(10);
286 | } else {
287 | make.bottom.and.right.offset(-10);
288 | }
289 | }];
290 | }
291 | ```
292 |
293 | You can find more detailed examples of all three approaches in the **Masonry iOS Examples** project.
294 |
295 | ## When the ^&*!@ hits the fan!
296 |
297 | Laying out your views doesn't always goto plan. So when things literally go pear shaped, you don't want to be looking at console output like this:
298 |
299 | ```obj-c
300 | Unable to simultaneously satisfy constraints.....blah blah blah....
301 | (
302 | "=5000)]>",
303 | "",
304 | "",
305 | ""
306 | )
307 |
308 | Will attempt to recover by breaking constraint
309 | =5000)]>
310 | ```
311 |
312 | Masonry adds a category to NSLayoutConstraint which overrides the default implementation of `- (NSString *)description`.
313 | Now you can give meaningful names to views and constraints, and also easily pick out the constraints created by Masonry.
314 |
315 | which means your console output can now look like this:
316 |
317 | ```obj-c
318 | Unable to simultaneously satisfy constraints......blah blah blah....
319 | (
320 | "",
321 | "= 5000>",
322 | "",
323 | ""
324 | )
325 |
326 | Will attempt to recover by breaking constraint
327 | = 5000>
328 | ```
329 |
330 | For an example of how to set this up take a look at the **Masonry iOS Examples** project in the Masonry workspace.
331 |
332 | ## Where should I create my constraints?
333 |
334 | ```objc
335 | @implementation DIYCustomView
336 |
337 | - (id)init {
338 | self = [super init];
339 | if (!self) return nil;
340 |
341 | // --- Create your views here ---
342 | self.button = [[UIButton alloc] init];
343 |
344 | return self;
345 | }
346 |
347 | // tell UIKit that you are using AutoLayout
348 | + (BOOL)requiresConstraintBasedLayout {
349 | return YES;
350 | }
351 |
352 | // this is Apple's recommended place for adding/updating constraints
353 | - (void)updateConstraints {
354 |
355 | // --- remake/update constraints here
356 | [self.button remakeConstraints:^(MASConstraintMaker *make) {
357 | make.width.equalTo(@(self.buttonSize.width));
358 | make.height.equalTo(@(self.buttonSize.height));
359 | }];
360 |
361 | //according to apple super should be called at end of method
362 | [super updateConstraints];
363 | }
364 |
365 | - (void)didTapButton:(UIButton *)button {
366 | // --- Do your changes ie change variables that affect your layout etc ---
367 | self.buttonSize = CGSize(200, 200);
368 |
369 | // tell constraints they need updating
370 | [self setNeedsUpdateConstraints];
371 | }
372 |
373 | @end
374 | ```
375 |
376 | ## Installation
377 | Use the [orsome](http://www.youtube.com/watch?v=YaIZF8uUTtk) [CocoaPods](http://github.com/CocoaPods/CocoaPods).
378 |
379 | In your Podfile
380 | >`pod 'Masonry'`
381 |
382 | If you want to use masonry without all those pesky 'mas_' prefixes. Add #define MAS_SHORTHAND to your prefix.pch before importing Masonry
383 | >`#define MAS_SHORTHAND`
384 |
385 | Get busy Masoning
386 | >`#import "Masonry.h"`
387 |
388 | ## Code Snippets
389 |
390 | Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your masonry blocks at lightning speed!
391 |
392 | `mas_make` -> `[ mas_makeConstraints:^(MASConstraintMaker *make){}];`
393 |
394 | `mas_update` -> `[ mas_updateConstraints:^(MASConstraintMaker *make){}];`
395 |
396 | `mas_remake` -> `[ mas_remakeConstraints:^(MASConstraintMaker *make){}];`
397 |
398 | ## Features
399 | * Not limited to subset of Auto Layout. Anything NSLayoutConstraint can do, Masonry can do too!
400 | * Great debug support, give your views and constraints meaningful names.
401 | * Constraints read like sentences.
402 | * No crazy macro magic. Masonry won't pollute the global namespace with macros.
403 | * Not string or dictionary based and hence you get compile time checking.
404 |
405 | ## TODO
406 | * Eye candy
407 | * Mac example project
408 | * More tests and examples
409 |
410 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/rong.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/rong.xcuserdatad/xcschemes/Pods.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/rong.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Masonry.xcscheme
8 |
9 | isShown
10 |
11 |
12 | Pods.xcscheme
13 |
14 | isShown
15 |
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 53480ED0BE09FF49E34B1702D485CAAB
21 |
22 | primary
23 |
24 |
25 | 660D7C18573951D8F09434C11E127EC4
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/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 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Masonry/Masonry.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry"
3 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit"
4 | PODS_ROOT = ${SRCROOT}
5 | SKIP_INSTALL = YES
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## Masonry
5 |
6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry
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 | Generated by CocoaPods - http://cocoapods.org
26 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-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) 2011-2012 Masonry Team - https://github.com/Masonry
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 | Title
37 | Masonry
38 | Type
39 | PSGroupSpecifier
40 |
41 |
42 | FooterText
43 | Generated by CocoaPods - http://cocoapods.org
44 | Title
45 |
46 | Type
47 | PSGroupSpecifier
48 |
49 |
50 | StringsTable
51 | Acknowledgements
52 | Title
53 | Acknowledgements
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods : NSObject
3 | @end
4 | @implementation PodsDummy_Pods
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | install_framework()
10 | {
11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
12 | local source="${BUILT_PRODUCTS_DIR}/$1"
13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
15 | elif [ -r "$1" ]; then
16 | local source="$1"
17 | fi
18 |
19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 |
21 | if [ -L "${source}" ]; then
22 | echo "Symlinked..."
23 | source="$(readlink "${source}")"
24 | fi
25 |
26 | # use filter instead of exclude so missing patterns dont' throw errors
27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
29 |
30 | local basename
31 | basename="$(basename -s .framework "$1")"
32 | binary="${destination}/${basename}.framework/${basename}"
33 | if ! [ -r "$binary" ]; then
34 | binary="${destination}/${basename}"
35 | fi
36 |
37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
39 | strip_invalid_archs "$binary"
40 | fi
41 |
42 | # Resign the code if required by the build settings to avoid unstable apps
43 | code_sign_if_enabled "${destination}/$(basename "$1")"
44 |
45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
47 | local swift_runtime_libs
48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
49 | for lib in $swift_runtime_libs; do
50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
52 | code_sign_if_enabled "${destination}/${lib}"
53 | done
54 | fi
55 | }
56 |
57 | # Signs a framework with the provided identity
58 | code_sign_if_enabled() {
59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
60 | # Use the current code_sign_identitiy
61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
64 | fi
65 | }
66 |
67 | # Strip invalid architectures
68 | strip_invalid_archs() {
69 | binary="$1"
70 | # Get architectures for current file
71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
72 | stripped=""
73 | for arch in $archs; do
74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
75 | # Strip non-valid architectures in-place
76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
77 | stripped="$stripped $arch"
78 | fi
79 | done
80 | if [[ "$stripped" ]]; then
81 | echo "Stripped $binary of architectures:$stripped"
82 | fi
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | XCASSET_FILES=()
10 |
11 | realpath() {
12 | DIRECTORY="$(cd "${1%/*}" && pwd)"
13 | FILENAME="${1##*/}"
14 | echo "$DIRECTORY/$FILENAME"
15 | }
16 |
17 | install_resource()
18 | {
19 | case $1 in
20 | *.storyboard)
21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
23 | ;;
24 | *.xib)
25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
27 | ;;
28 | *.framework)
29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
33 | ;;
34 | *.xcdatamodel)
35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
37 | ;;
38 | *.xcdatamodeld)
39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
41 | ;;
42 | *.xcmappingmodel)
43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
45 | ;;
46 | *.xcassets)
47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
49 | ;;
50 | /*)
51 | echo "$1"
52 | echo "$1" >> "$RESOURCES_TO_COPY"
53 | ;;
54 | *)
55 | echo "${PODS_ROOT}/$1"
56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
57 | ;;
58 | esac
59 | }
60 |
61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
63 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
66 | fi
67 | rm -f "$RESOURCES_TO_COPY"
68 |
69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
70 | then
71 | case "${TARGETED_DEVICE_FAMILY}" in
72 | 1,2)
73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
74 | ;;
75 | 1)
76 | TARGET_DEVICE_ARGS="--target-device iphone"
77 | ;;
78 | 2)
79 | TARGET_DEVICE_ARGS="--target-device ipad"
80 | ;;
81 | *)
82 | TARGET_DEVICE_ARGS="--target-device mac"
83 | ;;
84 | esac
85 |
86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
88 | while read line; do
89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
90 | XCASSET_FILES+=("$line")
91 | fi
92 | done <<<"$OTHER_XCASSETS"
93 |
94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
95 | fi
96 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry"
3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry"
4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit"
5 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry"
3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry"
4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit"
5 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | 
4 |
5 |
6 | # iosAnimation
7 | # ios-animation
8 | AnimationTypeNormal, //UIview封装普通动画
9 | AnimationTypeSpring, //UIview封装弹簧动画
10 | AnimationTypeKeyframe, //UIview封装关键帧动画
11 | AnimationTransition, //UIview封装转场动画
12 | AnimationTypeCALayer, //CALayer动画
13 | AnimationTypeCALayerDraw, //CALayer绘图
14 | AnimationTypeCoreBase, //Core Animation 基础动画
15 | AnimationTypeCoreKeyframe, //Core Animation 关键帧动画
16 | AnimationTypeCoreGroup, //Core Animation 动画组
17 | AnimationTypeCoreTranform, //Core Animation 转场动画
18 | AnimationTypeCoreCADisplayLink //Core Animation 逐帧动画
19 |
20 |
21 |
--------------------------------------------------------------------------------
/animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rongshutou/iOS-Animation/35beabf64138e242a399a10bbdd232afeaafe01c/animation.gif
--------------------------------------------------------------------------------