zoukankan      html  css  js  c++  java
  • Masonry(第三方库)的使—代码实现屏幕适配

    #import"Masonry"

    实现效果图

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.
        [self testBasicLayout];
        [self testThreeLayout];
    }
    - (void)testThreeLayout
    {
        UIView *redView = [[UIView alloc] init];
        redView.backgroundColor = [UIColor redColor];
        [self.view addSubview:redView];
        
        UIView *blueView = [[UIView alloc] init];
        blueView.backgroundColor = [UIColor blueColor];
        [self.view addSubview:blueView];
        
        UIView *greenView = [[UIView alloc] init];
        greenView.backgroundColor = [UIColor greenColor];
        [self.view addSubview:greenView];
        
        [redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(50);
            make.left.mas_equalTo(50);
            make.right.mas_equalTo(-50);
            make.height.mas_equalTo(100);
        }];
        [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(redView.mas_bottom).offset(50);//偏移量 默认0
            make.left.mas_equalTo(50);
            make.height.mas_equalTo(100);
            //make.width.mas_equalTo(100);
        }];
        [greenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(redView.mas_bottom).offset(50);
            make.right.mas_equalTo(-50);
            make.height.mas_equalTo(100);
            make.width.mas_equalTo(100);
            
            //间隔固定,宽度相等
            make.left.mas_equalTo(blueView.mas_right).offset(50);
            make.width.mas_equalTo(blueView.mas_width);
        }];
    }
    - (void)testBasicLayout
    {
        //靠右对齐,100x100,top-50 right-50
        UIView *redView = [[UIView alloc] init];
        redView.backgroundColor = [UIColor redColor];
        [self.view addSubview:redView];
        //block重要参数:mark参数,设置make的属性。控制布局
        /*
        [redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(100);
            make.top.mas_equalTo(50);
            make.right.mas_equalTo(-50);
            
        }];
         */
        [redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(50);
            make.left.mas_equalTo(50);
            make.right.mas_equalTo(-50);
            make.height.mas_equalTo(100);
        }];
    }
    View Code
  • 相关阅读:
    文件系统
    Java的日志模块
    SQL Server 的索引结构实例
    SQL索引优化
    索引最佳实践
    SQL优化基础 使用索引(一个小例子)
    v使用索引的注意事项及常见场景、案例
    使用索引的注意事项及常见场景、案例
    SQL性能优化十条经验
    如何使用JVisualVM进行性能分析
  • 原文地址:https://www.cnblogs.com/caolongs/p/4774113.html
Copyright © 2011-2022 走看看