123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //
- // BViewController.m
- // MainProject
- //
- // Created by casa on 2016/12/10.
- // Copyright © 2016年 casa. All rights reserved.
- //
- #import "BViewController.h"
- @interface BViewController ()
- @property (nonatomic, strong) UILabel *contentLabel;
- @end
- @implementation BViewController
- #pragma mark - life cycle
- - (instancetype)initWithContentText:(NSString *)contentText
- {
- self = [super init];
- if (self) {
- self.contentLabel.text = contentText;
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.contentLabel];
- }
- - (void)viewWillLayoutSubviews
- {
- [super viewWillLayoutSubviews];
- [self.contentLabel sizeToFit];
- self.contentLabel.frame = CGRectMake(0, 0, 300, 100);
- self.contentLabel.center = self.view.center;
- }
- #pragma mark - getters and setters
- - (UILabel *)contentLabel
- {
- if (_contentLabel == nil) {
- _contentLabel = [[UILabel alloc] init];
- _contentLabel.textColor = [UIColor blueColor];
- }
- return _contentLabel;
- }
- @end
|