MASExampleLayoutGuideViewController.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 *bottomView = UIView.new;
  27. bottomView.backgroundColor = UIColor.redColor;
  28. bottomView.layer.borderColor = UIColor.blackColor.CGColor;
  29. bottomView.layer.borderWidth = 2;
  30. [self.view addSubview:bottomView];
  31. [topView makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.equalTo(self.mas_topLayoutGuide);
  33. make.left.equalTo(self.view);
  34. make.right.equalTo(self.view);
  35. make.height.equalTo(@40);
  36. }];
  37. [bottomView makeConstraints:^(MASConstraintMaker *make) {
  38. make.bottom.equalTo(self.mas_bottomLayoutGuide);
  39. make.left.equalTo(self.view);
  40. make.right.equalTo(self.view);
  41. make.height.equalTo(@40);
  42. }];
  43. }
  44. @end