Mansory的简单使用


1.lable自适应高度

 UILabel *lable = [[UILabel alloc]init];
    
    lable.backgroundColor = [UIColor whiteColor];
    lable.text = @"是点击四个挤到佛教给对方加工件都构建偶家二极管日接口了大杀四方莱克斯顿,是发动机盖我几十个及地方机构我奇偶加尔文公祭日公积金都是类控件的房价高的";
    lable.font = [UIFont systemFontOfSize:20];
    lable.textColor = [UIColor redColor];
    lable.numberOfLines = 0;
    [scrollView addSubview:lable];
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(greenView);
        make.top.equalTo(greenView.mas_bottom).offset(12);
        

    }];

2.UIScrollView的contenSize自适应

UIScrollView *scrollView = [[UIScrollView alloc]init];
    scrollView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:scrollView];
    
    UIView *contentView= [[UIView alloc]init];
    contentView.backgroundColor = [UIColor orangeColor];
    [scrollView addSubview:contentView];
    
    UIView *redView = [[UIView alloc]init];
    redView.backgroundColor = [UIColor redColor];
    [scrollView addSubview: redView];
    
    UIView *yeallowView = [[UIView alloc]init];
    yeallowView.backgroundColor = [UIColor yellowColor];
    [scrollView addSubview:yeallowView];
    
    UIView *greenView = [[UIView alloc]init];
    greenView.backgroundColor = [UIColor greenColor];
    [scrollView addSubview:greenView];
    
    UIView *lightView = [[UIView alloc]init];
    lightView.backgroundColor = [UIColor lightGrayColor];
    [scrollView addSubview:lightView];
    
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    CGFloat padding = 25.0;

[greenView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(scrollView).offset(padding);
        make.size.mas_equalTo(CGSizeMake(250, 250));
        
    }];
    
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(greenView.mas_bottom).offset(padding);
        make.left.equalTo(greenView.mas_right).offset(padding);
        make.size.equalTo(greenView);
        make.right.equalTo(scrollView).offset(-padding);
      
    }];
    
    [yeallowView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(scrollView).offset(padding);
        make.top.equalTo(redView.mas_bottom).offset(padding);
        make.size.equalTo(greenView);
        make.bottom.equalTo(scrollView).offset(-padding);
      
    }];
   

3.TableViewCell的自适应

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
    [tableView registerClass:[TestCell class] forCellReuseIdentifier:@"cell"];
    tableView.delegate = self;
    tableView.dataSource =self;
    tableView.rowHeight = UITableViewAutomaticDimension;
    [self.view addSubview:tableView];
   
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    return cell;
    
    

}

自定义cell里面的主要代码

    UILabel *titleLb = [[UILabel alloc]init];
    titleLb.textColor  =[UIColor redColor];
    titleLb.numberOfLines = 0;
    titleLb.text = @"是都加哦我接发动is加都加个介绍的 就放商店防静电房管局死哦的几个我偶家死哦接我 我加个我我就都给我就是地方官基数低计算机那是块几点放圣诞节梵蒂冈我我就诶关键人物 ";
    [self.contentView addSubview:titleLb];
    
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(30);
        make.top.equalTo(self.contentView).offset(20);
        make.bottom.equalTo(self.contentView).offset(-20);
    }];
   



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值