iOS 代码布局
1个回答
展开全部
UILabel *lbgz=[[UILabel alloc]initWithFrame:CGRectZero];
lbgz.backgroundColor=[UIColor grayColor];
lbgz.text=@"工种";
lbgz.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:lbgz];
self.gzCombox=[[myCombox alloc]initWithFrame:CGRectZero];
self.gzCombox.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:self.gzCombox];
NSLayoutConstraint *lbgzx=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:10];
NSLayoutConstraint *lbgzy=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:80];
NSLayoutConstraint *lbgzw=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0 constant:40];
NSLayoutConstraint *lbgzh=[NSLayoutConstraint constraintWithItem:lbgz attribute: NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:0 constant:40];
NSLayoutConstraint *gzx=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:70];
NSLayoutConstraint *gzy=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:80];
NSLayoutConstraint *gzw=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0 constant:120];
NSLayoutConstraint *gzh=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute: NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:0 constant:40];
[self.view addConstraints:@[lbgzx,lbgzy,lbgzw,lbgzh]];
[self.view addConstraints:@[gzh,gzw,gzx,gzy]];
lbgz.backgroundColor=[UIColor grayColor];
lbgz.text=@"工种";
lbgz.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:lbgz];
self.gzCombox=[[myCombox alloc]initWithFrame:CGRectZero];
self.gzCombox.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:self.gzCombox];
NSLayoutConstraint *lbgzx=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:10];
NSLayoutConstraint *lbgzy=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:80];
NSLayoutConstraint *lbgzw=[NSLayoutConstraint constraintWithItem:lbgz attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0 constant:40];
NSLayoutConstraint *lbgzh=[NSLayoutConstraint constraintWithItem:lbgz attribute: NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:0 constant:40];
NSLayoutConstraint *gzx=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:70];
NSLayoutConstraint *gzy=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:80];
NSLayoutConstraint *gzw=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0 constant:120];
NSLayoutConstraint *gzh=[NSLayoutConstraint constraintWithItem:self.gzCombox attribute: NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:0 constant:40];
[self.view addConstraints:@[lbgzx,lbgzy,lbgzw,lbgzh]];
[self.view addConstraints:@[gzh,gzw,gzx,gzy]];
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询