zoukankan      html  css  js  c++  java
  • ios

    #import "ViewController.h"
    #import "Masonry.h"
    #define kWeakSelf(weakSelf) __weak typeof(self)weakSelf = self
    #define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self
    @interface ViewController ()
    {
        UIView *topView;
    }
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        kWeakSelf(ws);
        /**底部灰色view*/
        topView = [[UIView alloc]init];
        topView.backgroundColor = [UIColor lightGrayColor];
        [ws.view addSubview:topView];
        [topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(ws.view);
            make.size.mas_equalTo(CGSizeMake(300, 300));
            
              }];
        /**表面红色view*/
        UIView *redView= [[UIView alloc]init];
        redView.backgroundColor = [UIColor redColor];
        [topView addSubview:redView];
        [redView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.edges.equalTo(topView).with.insets(UIEdgeInsetsMake(10, 10, 10, 10));
            
        }];
        
        /**
         创建三个等宽等高等间距view
         */
        /**左边view*/
        UIView *leftView = [[UIView alloc]init];
        leftView.backgroundColor = [UIColor blueColor];
        [redView addSubview:leftView];
        /**右边view*/
        UIView *rightView = [[UIView alloc]init];
        rightView.backgroundColor = [UIColor brownColor];
        [redView addSubview:rightView];
        
        /**最有边view*/
        UIView *lastView = [[UIView alloc]init];
        lastView.backgroundColor = [UIColor yellowColor];
        [redView addSubview:lastView];
        
        CGFloat padding = 10.f;
        //左边view添加约束
        [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(redView.mas_centerY);
            make.left.equalTo(redView.mas_left).with.offset(padding);
            make.right.equalTo(rightView.mas_left).with.offset(-padding);
            make.height.mas_equalTo(@150);
            make.width.equalTo(rightView);
        }];
         //右边view添加约束
        [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.centerY.mas_equalTo(redView.mas_centerY);
            make.left.equalTo(leftView.mas_right).with.offset(padding);
            make.right.equalTo(lastView.mas_left).with.offset(-padding);
            
            make.height.mas_equalTo(@150);
            make.width.equalTo(lastView);
            
        }];
         //最右边view添加约束
        [lastView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerY.mas_equalTo(redView.mas_centerY);
            make.left.equalTo(rightView.mas_right).with.offset(padding);
            make.right.equalTo(redView.mas_right).with.offset(-padding);
            make.width.equalTo(rightView);
            make.height.mas_equalTo(@150);
        }];
       }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
       
    }
    
    @end

  • 相关阅读:
    SpringBoot入门系列
    日志收集系统-多线程消息队列
    阿里云ecs 服务器配置
    MySQL 表分区详解MyiSam引擎和InnoDb 区别(实测)
    Redis 3.2 Linux 环境集群搭建与java操作
    Java
    多线程编程-工具篇-BlockingQueue
    java常见面试题及答案 11-20(JVM篇)
    28.function_score自定义相关度分数算法
    27.四种常见的相关度分数优化方法
  • 原文地址:https://www.cnblogs.com/thbbsky/p/4530901.html
Copyright © 2011-2022 走看看