MASExampleLayoutGuideViewController.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // MASExampleLayoutGuideViewController.m
  3. // Masonry iOS Examples
  4. //
  5. // Created by Jonas Budelmann on 26/11/13.
  6. // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
  7. //
  8. #import "MASExampleLayoutGuideViewController.h"
  9. @interface MASExampleLayoutGuideViewController ()
  10. @end
  11. @implementation MASExampleLayoutGuideViewController
  12. - (id)init {
  13. self = [super init];
  14. if (!self) return nil;
  15. self.title = @"Layout Guides";
  16. return self;
  17. }
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.view.backgroundColor = [UIColor whiteColor];
  21. UIView *topView = UIView.new;
  22. topView.backgroundColor = UIColor.greenColor;
  23. topView.layer.borderColor = UIColor.blackColor.CGColor;
  24. topView.layer.borderWidth = 2;
  25. [self.view addSubview:topView];
  26. UIView *topSubview = UIView.new;
  27. topSubview.backgroundColor = UIColor.blueColor;
  28. topSubview.layer.borderColor = UIColor.blackColor.CGColor;
  29. topSubview.layer.borderWidth = 2;
  30. [topView addSubview:topSubview];
  31. UIView *bottomView = UIView.new;
  32. bottomView.backgroundColor = UIColor.redColor;
  33. bottomView.layer.borderColor = UIColor.blackColor.CGColor;
  34. bottomView.layer.borderWidth = 2;
  35. [self.view addSubview:bottomView];
  36. [topView makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.equalTo(self.mas_topLayoutGuide);
  38. make.left.equalTo(self.view);
  39. make.right.equalTo(self.view);
  40. make.height.equalTo(@40);
  41. }];
  42. [topSubview makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.equalTo(self.mas_topLayoutGuide);
  44. make.centerX.equalTo(@0);
  45. make.width.equalTo(@20);
  46. make.height.equalTo(@20);
  47. }];
  48. [bottomView makeConstraints:^(MASConstraintMaker *make) {
  49. make.bottom.equalTo(self.mas_bottomLayoutGuide);
  50. make.left.equalTo(self.view);
  51. make.right.equalTo(self.view);
  52. make.height.equalTo(@40);
  53. }];
  54. }
  55. @end