AViewController.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // AViewController.m
  3. // MainProject
  4. //
  5. // Created by casa on 2016/12/10.
  6. // Copyright © 2016年 casa. All rights reserved.
  7. //
  8. #import "AViewController.h"
  9. @interface AViewController ()
  10. @property (nonatomic, strong) UIButton *pushBViewControllerButton;
  11. @property (nonatomic, strong) UIButton *loginBtn;
  12. @end
  13. @implementation AViewController
  14. #pragma mark - life cycle
  15. - (void)viewDidLoad
  16. {
  17. [super viewDidLoad];
  18. self.view.backgroundColor = [UIColor whiteColor];
  19. [self.view addSubview:self.pushBViewControllerButton];
  20. [self.view addSubview:self.loginBtn];
  21. }
  22. - (void)viewWillLayoutSubviews
  23. {
  24. [super viewWillLayoutSubviews];
  25. [self.pushBViewControllerButton sizeToFit];
  26. self.pushBViewControllerButton.frame = CGRectMake(0, 0, 300, 100);
  27. self.pushBViewControllerButton.center = self.view.center;
  28. self.loginBtn.frame = CGRectMake(20, CGRectGetMaxY(self.pushBViewControllerButton.frame)+30, 100, 100);
  29. }
  30. #pragma mark - event response
  31. - (void)didTappedPushBViewControllerButton:(UIButton *)button
  32. {
  33. UIViewController *viewController = [[CTMediator sharedInstance] Goods_GoodsDetaileC:@{@"entity_id":@"40018"}];
  34. [self.navigationController pushViewController:viewController animated:YES];
  35. }
  36. -(void)buttonTap:(UIButton *)btn{
  37. UIViewController *login = [[CTMediator sharedInstance] Login_LoginC:@{}];
  38. login.modalPresentationStyle = UIModalPresentationFullScreen;
  39. [self.navigationController presentViewController:login animated:YES completion:nil];
  40. }
  41. #pragma mark - getters and setters
  42. - (UIButton *)pushBViewControllerButton
  43. {
  44. if (_pushBViewControllerButton == nil) {
  45. _pushBViewControllerButton = [UIButton buttonWithType:UIButtonTypeCustom];
  46. [_pushBViewControllerButton setTitle:@"push B view controller" forState:UIControlStateNormal];
  47. [_pushBViewControllerButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
  48. [_pushBViewControllerButton addTarget:self action:@selector(didTappedPushBViewControllerButton:) forControlEvents:UIControlEventTouchUpInside];
  49. }
  50. return _pushBViewControllerButton;
  51. }
  52. - (UIButton *)loginBtn {
  53. if (!_loginBtn) {
  54. _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  55. [_loginBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  56. _loginBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  57. [_loginBtn setTitle:@"ligoin" forState:UIControlStateNormal];
  58. [_loginBtn addTarget:self action:@selector(buttonTap:) forControlEvents:UIControlEventTouchUpInside];
  59. }
  60. return _loginBtn;
  61. }
  62. @end