IOS 学习之路(一) 徒手写界面(3)使用框架

来源:互联网 发布:万国数据是干嘛的 编辑:程序博客网 时间:2024/05/16 09:02

有么有觉得原来的定位太麻烦了哪!
我们来使用一个比较简单,我也很喜欢的框架Masonry吧
他的用法很简单
我们创建一个方法叫layouinsubview 我们把控件定位全部都放在这里

-(void)layouinsubview{    [self.PhoneLable mas_makeConstraints:^(MASConstraintMaker *make) {        make.size.mas_equalTo(CGSizeMake(45, 20));        make.top.mas_equalTo(130);        make.left.mas_equalTo(30);    }];    [self.PhoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width-110, 20));        make.left.equalTo(_PhoneLable.mas_left).with.offset(50);        make.top.mas_equalTo(130);    }];}

用着特别好用,能对控件与控件进行距离控制,看着还舒服
然后在

- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    UITapGestureRecognizer * ForgetPwdLabeljump = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelClick)];    self.view.backgroundColor = [UIColor grayColor];    [self.view addSubview:self.PhoneLable];    [self.view addSubview:self.PhoneTextField];    [self.view addSubview:self.oneLabel];    [self.view addSubview:self.PasswordLable];    [self.view addSubview:self.PwdTextField];    [self.view addSubview:self.towLabel];    [self.view addSubview:self.enterbtn];    [self.view addSubview:self.ForgetPwdLabel];    [self.view addSubview:self.RegistrationLabel];    [self layouinsubview];}

使用一下就好了。
这个就是简单的框架使用 如果要看如何合理的用 我出一篇外传吧!
嘿嘿!

0 0