Once
Articles25
Tags10
Categories0
OnceLayout布局

OnceLayout布局

告别繁重的代码,只需简单的几行就完成布局.

UIView * view_one=[[UIView alloc]init];
    view_one.backgroundColor=[UIColor redColor];
    [self.view addSubview:view_one];
    view_one.width=50;
    view_one.height=50;
    view_one.once_rightToView(self.view, 10);
    view_one.once_topToView(self.view, 20);
    
    
    UIView * view_two=[[UIView alloc]init];
    view_two.backgroundColor=[UIColor purpleColor];
    [self.view addSubview:view_two];
    view_two.width=200;
    view_two.height=200;
    view_two.once_rightToView(self.view, 100);
    view_two.once_topToView(self.view, 200);
    
    
    UIView * view_three=[[UIView alloc]init];
    view_three.backgroundColor=[UIColor greenColor];
    [view_two addSubview:view_three];
    view_three.width=80;
    view_three.height=80;
    view_three.once_leftToView(view_two, 20);
    view_three.once_topToView(view_two, 30);
    
    UIView * view_four=[[UIView alloc]init];
    view_four.backgroundColor=[UIColor greenColor];
    [self.view addSubview:view_four];
    view_four.width=80;
    view_four.height=80;
    view_four.once_leftToView(view_two, 20);
    view_four.once_topToView(view_two, 30);
    
    
    UIView * view_five=[[UIView alloc]init];
    view_five.backgroundColor=[UIColor greenColor];
    [self.view addSubview:view_five];
    view_five.width=80;
    view_five.height=80;
    view_five.once_topToView(view_two, 20);
    view_five.once_rightToView(self.view, 30);
Author:Once
Link:http://once00.github.io/2018/04/10/OnceLayout%E5%B8%83%E5%B1%80/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可