OC Extension View+X+Y+Width+Height(自定义约束)

一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。

OC 项目底层框架(万能)

View+X+Y+Width+Height(自定义约束)下载链接

在这里插入图片描述
注意:
1,必须先设置宽高,再设置上下左右的位置
填写父view的关系

self.viewA = [[UIView alloc] init];
self.viewA.addTo(self.view).bgColor(@"random");

self.viewB = [[UIView alloc] init];
self.viewB.addTo(self.view).bgColor(@"random");

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocLeft;
self.viewB.ocTop = self.viewA.ocTop;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocRight;
self.viewB.ocTop = self.viewA.ocTop;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocRight;
self.viewB.ocTop = self.viewA.ocBottom;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocLeft;
self.viewB.ocTop = self.viewA.ocBottom;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocRight = self.view.bounds.size.width - self.viewA.ocLeft;
self.viewB.ocTop = self.viewA.ocBottom;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocRight = self.view.bounds.size.width - self.viewA.ocLeft;
self.viewB.ocTop = self.viewA.ocTop;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocRight = self.view.bounds.size.width - self.viewA.ocLeft;
self.viewB.ocBottom = self.view.bounds.size.height - self.viewA.ocTop;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocLeft;
self.viewB.ocBottom = self.view.bounds.size.height - self.viewA.ocTop;

在这里插入图片描述

self.viewA.ocWidth = 50;
self.viewA.ocHeight = 50;
self.viewA.ocLeft = 150;
self.viewA.ocTop = 150;

self.viewB.ocWidth = 50;
self.viewB.ocHeight = 50;
self.viewB.ocLeft = self.viewA.ocRight;
self.viewB.ocBottom = self.view.bounds.size.height - self.viewA.ocTop;

在这里插入图片描述

B的centerY等于A的centerY , B靠右边15

    self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Phone_Width, HeaderView)];
    self.headerView.addTo(self.view).bgColor([Color theme]);
    
    self.brandImg = [UIImageView new];
    self.brandImg.addTo(self.headerView).bgColor([Color randomColor]).xywh(15,statusHeight+5,46,46).borderRadius(23);

    self.headerBtn = [UIButton new];
    self.headerBtn.addTo(self.headerView).bgColor([Color randomColor]).borderRadius(15);
    self.headerBtn.ocWidth = 30;
    self.headerBtn.ocHeight = 30;
    self.headerBtn.ocCenterY = self.brandImg.ocCenterY;
    self.headerBtn.ocRight = 15;

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冯汉栩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值