masonry 四个控件纵向对齐===关键点是 centerX是要对齐的

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cos_sin_tan/article/details/50846147
 
 #pragma mark 添加录音view
-(void)addRecord{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, [[UIScreen mainScreen] bounds].size.height - 130 , [[UIScreen mainScreen]bounds].size.width -20, [[UIScreen mainScreen] bounds].size.height)];
    
    view.backgroundColor = [UIColor  colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:0.6];
    
    
    //取消录音
    UIButton *btnCancle = [[UIButton alloc]init];
    [btnCancle setTitle:@"取消" forState:UIControlStateNormal];
    [btnCancle addTarget:self action:@selector(cancleRecord) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btnCancle];
    [btnCancle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
    }];
    

    //确定录音
    UIButton *btnOK = [[UIButton alloc]init];
    [btnOK setTitle:@"完成" forState:UIControlStateNormal];
    [btnOK addTarget:self action:@selector(recordOk) forControlEvents:UIControlEventTouchUpInside];
    
    [view addSubview:btnOK];
    [btnOK mas_makeConstraints:^(MASConstraintMaker *make){
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(40);
        make.top.equalTo(view).with.offset(10);
        make.right.equalTo(view).with.offset(-10);
    }];
    
    
    //录音imageview
    UIImageView *recordImageView = [[UIImageView alloc]init];
    recordImageView.image = [UIImage imageNamed:@"RecordluIco"];
    [view addSubview:recordImageView];
    [recordImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(view);
        make.top.mas_equalTo(60);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
        
    }];
    
    //显示时间的button
    UIButton *btnTime = [[UIButton alloc]init];
    self.btnTime = btnTime;
    [btnTime setTitle:@"00:00:00" forState:UIControlStateNormal];
    [view addSubview:btnTime];
    [btnTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(view);
        make.top.mas_equalTo(recordImageView.mas_bottom).with.offset(10);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(100);
    }];
    
    UIImageView *imageViewStart = [[UIImageView alloc]init];
    imageViewStart.image =[UIImage imageNamed:@"RecordlyTime"];
    [view addSubview:imageViewStart];
    [imageViewStart mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(view);
        make.top.mas_equalTo(btnTime.mas_bottom).with.offset(10);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
        
    }];
    
    UIButton *btnStart = [[UIButton alloc]init];
    self.btnStartRecord = btnStart;
    [btnStart setTitle:@"开始录音" forState:UIControlStateNormal];
    [btnStart addTarget:self action:@selector(startRecord) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btnStart];
    [btnStart mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(view);
        make.top.mas_equalTo(imageViewStart.mas_bottom).with.offset(10);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(100);
        
    }];
    
    [self.view addSubview:view];
    
    self.recordView = view;
}

阅读更多

没有更多推荐了,返回首页