UIView: addView

把视图 一起 添加了。


class func addViews(views: Array , onViewController viewController: UIViewController ) {
    
        
        for view in views {
        
        
            viewController.view.addSubview(view)
        
        
        }
        
    }


 AutoLayout

ÓÓ Masonry

一定要 先 添加 View,
再 给 View 约束。


- (void)viewDidLoad {
    [super viewDidLoad];
    
    __weak typeof (self) weakSelf = self;
    UIView * viewOne = [[UIView alloc ] init ];
    [self.view addSubview: viewOne ];
    [viewOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weakSelf.view).with.insets(UIEdgeInsetsMake(20, 20, 20, 20));
        
    }];
    viewOne.backgroundColor = [UIColor cyanColor ];
//    [self.view addSubview: viewOne ];

你可能感兴趣的:(UIView: addView)