Masonry适配——(6)登录视图示例
来源:互联网 发布:南京seo 编辑:程序博客网 时间:2024/06/05 11:32
github:https://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
- Masonry适配——(6)登录视图示例
- Masonry适配——(2)使用方法
- Masonry适配——(2)使用方法
- Masonry框架使用示例(转载)
- Masonry适配——(1)使用注意事项
- Masonry适配——(4)UIScrollView的设置
- Masonry适配——(1)使用注意事项
- Masonry适配——(4)UIScrollView的设置
- Masonry适配——(5)animation动画的设置
- Masonry适配——(8)UICollectionView的使用
- 【Struts】——登录示例
- Masonry — 代码约束
- Masonry 使用总结(示例)
- 有趣的Autolayout示例2-Masonry实现(转)
- Masonry适配——(3)UILable如何设置多行显示
- Masonry适配——(3)UILable如何设置多行显示
- Masonry适配——(7)UITableView中自定义UITableViewCell高度自适应及计算
- iPhone6+ 以及 iOS8适配:Masonry介绍——速成Autolayout
- 【菜鸟数据库学习日记】从头开始学MySQL(4)
- HTTP协议之multipart/form-data请求分析
- 分布式集群Session共享 简单多tomcat8+redis的session共享实现
- JS - 作用域和上下文环境
- Unity3D占用内存太大的解决方法
- Masonry适配——(6)登录视图示例
- LEETCODE--Number Complement
- IOS ARC下内存泄露总结
- Android基站定位——通过手机信号获取基站信息(一)
- 《企业云桌面实施》-小技巧-01-规划注意事项
- DOM 元素
- linux多线程之条件变量
- Minimum Path Sum
- java代码发送邮件,并携带附件