「OC」登陆界面
明确要求
一个登陆界面的组成,用户名提示以及输入框,密码提示提示以及输入框,登陆按钮,以及注册按钮,根据以上要求我们将我们的组件设置为成员变量。
//viewControl.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (nonatomic) UILabel *lUserName;
@property (nonatomic) UILabel *lPassword;
@property (nonatomic) UITextField *tsUserName;
@property (nonatomic) UITextField *stPassword;
@property (nonatomic) UIButton *btnLogin;
@property (nonatomic) UIButton *btnRegister;
@end
界面设置
根据以上的组件,我们可以将组件进行编排,代码如下,可根据自身审美进行相关的排版
//viewControl.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
_lUserName = [[UILabel alloc] initWithFrame:CGRectMake(20, 200, 80, 40)];
_lUserName.text = @"用户名:";
_lUserName.font = [UIFont systemFontOfSize:20];
_lUserName.textAlignment = NSTextAlignmentLeft;
_lPassword = [[UILabel alloc] initWithFrame:CGRectMake(20, 260, 80, 40)];
_lPassword.text = @"密码:";
_lPassword.font = [UIFont systemFontOfSize:20];
_lPassword.textAlignment = NSTextAlignmentLeft;
_tsUserName = [[UITextField alloc] initWithFrame:CGRectMake(120, 200, 180, 40)];
_tsUserName.placeholder = @"请输入用户名";
_stPassword = [[UITextField alloc] initWithFrame:CGRectMake(120, 260, 180, 40)];
_stPassword.placeholder = @"请输入密码";
_stPassword.borderStyle = UITextBorderStyleRoundedRect;
_stPassword.secureTextEntry = YES;
_btnLogin = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 80, 40)];
_btnLogin.backgroundColor = [UIColor redColor];
[_btnLogin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_btnLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
[_btnLogin setTitle:@"登录" forState:UIControlStateNormal

最低0.47元/天 解锁文章
325

被折叠的 条评论
为什么被折叠?



