Masonry适配——(6)登录视图示例

来源:互联网 发布:南京seo 编辑:程序博客网 时间:2024/06/05 11:32

githubhttps://github.com/potato512/SYDemo_Masonry

效果图


// 头像UIImageView *headerImageView = [[UIImageView alloc] init];[self.view addSubview:headerImageView];[headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(30.0);        make.centerX.mas_equalTo(self.view.mas_centerX);        make.size.mas_equalTo(CGSizeMake(90.0, 90.0));}];headerImageView.layer.cornerRadius = 45.0;headerImageView.layer.masksToBounds = YES;headerImageView.clipsToBounds = YES;headerImageView.backgroundColor = RandomColor;headerImageView.image = [UIImage imageNamed:@"futou"];
// 视图变量,用于传递上一个视图的尺寸坐标UIView *currentView = headerImageView;
// 昵称UILabel *nameLabel = [[UILabel alloc] init];[self.view addSubview:nameLabel];[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(currentView.mas_bottom).offset(10);        make.left.mas_equalTo(10);        make.right.mas_equalTo(-10);        make.height.mas_equalTo(20);}];nameLabel.textColor = [UIColor blackColor];nameLabel.textAlignment = NSTextAlignmentCenter;nameLabel.text = @"devZhang 135***000";nameLabel.font = [UIFont systemFontOfSize:15.0];    currentView = nameLabel;
// 分割线UIView *lineView = [[UIView alloc] init];[self.view addSubview:lineView];[lineView mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(currentView.mas_bottom).offset(10);        make.left.mas_equalTo(currentView.left);        make.width.equalTo(currentView);        make.height.mas_equalTo(@1);}];lineView.backgroundColor = [UIColor grayColor];    currentView = lineView;
// 帐号UITextField *nameTextField = [[UITextField alloc] init];[self.view addSubview:nameTextField];[nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(currentView.mas_bottom).with.offset(10);        make.left.mas_equalTo(10);        make.right.mas_equalTo(-10);        make.height.mas_equalTo(40);}];nameTextField.clearButtonMode = UITextFieldViewModeWhileEditing;nameTextField.placeholder = @"请输入登录帐号";nameTextField.textColor = [UIColor blackColor];nameTextField.font = [UIFont systemFontOfSize:12.0];nameTextField.layer.cornerRadius = 5.0;nameTextField.layer.masksToBounds = YES;nameTextField.layer.borderColor = RandomColor.CGColor;nameTextField.layer.borderWidth = 1.0;nameTextField.delegate = self;    currentView = nameTextField;
// 密码UITextField *passwordTextField = [[UITextField alloc] init];[self.view addSubview:passwordTextField];[passwordTextField mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(currentView.mas_bottom).with.offset(10);        make.left.mas_equalTo(10);        make.right.mas_equalTo(-10);        make.height.mas_equalTo(40);}];passwordTextField.clearButtonMode = UITextFieldViewModeWhileEditing;passwordTextField.placeholder = @"请输入登录密码";passwordTextField.textColor = [UIColor blackColor];passwordTextField.font = [UIFont systemFontOfSize:12.0];passwordTextField.secureTextEntry = YES;passwordTextField.layer.cornerRadius = 5.0;passwordTextField.layer.masksToBounds = YES;passwordTextField.layer.borderColor = RandomColor.CGColor;passwordTextField.layer.borderWidth = 1.0;passwordTextField.delegate = self;currentView = passwordTextField;
// 登录UIButton *loginButton = [[UIButton alloc] init];[self.view addSubview:loginButton];[loginButton mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(currentView.mas_bottom).offset(10);        make.left.mas_equalTo(10);        make.right.mas_equalTo(-10);        make.height.mas_equalTo(currentView.mas_height);}];loginButton.layer.cornerRadius = 5.0;loginButton.layer.masksToBounds = YES;[loginButton setTitle:@"登录" forState:UIControlStateNormal];loginButton.backgroundColor = RandomColor;loginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;[loginButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[loginButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];    currentView = loginButton;
// 快速注册UIButton *registerButton = [[UIButton alloc] init];[self.view addSubview:registerButton];[registerButton mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(currentView.mas_bottom).offset(10);        make.left.mas_equalTo(10);        make.width.mas_equalTo(100);        make.height.mas_equalTo(currentView.mas_height);}];[registerButton setTitle:@"快速注册" forState:UIControlStateNormal];registerButton.backgroundColor = [UIColor clearColor];registerButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;[registerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[registerButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
// 忘记密码UIButton *forgetButton = [[UIButton alloc] init];[self.view addSubview:forgetButton];[forgetButton mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.mas_equalTo(currentView.mas_bottom).offset(10);        make.right.mas_equalTo(-10);        make.width.mas_equalTo(100);        make.height.mas_equalTo(currentView.mas_height);}];[forgetButton setTitle:@"找回密码" forState:UIControlStateNormal];forgetButton.backgroundColor = [UIColor clearColor];forgetButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;[forgetButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[forgetButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];










0 0