.m中部分代码, 模拟简易的登陆界面
UIView *labelBackground = [[UIView alloc] initWithFrame:CGRectMake(20, 60, 280, 150)];
[labelBackground setBackgroundColor:[UIColor lightGrayColor]];
labelBackground.alpha = 0.35;
[self.window addSubview:labelBackground];
labelBackground.layer.cornerRadius = 10;
UILabel *enter = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 60, 20)];
[enter setBackgroundColor:[UIColor cyanColor]];
enter.text = @"账号";
enter.textAlignment = NSTextAlignmentCenter;
enter.textColor = [UIColor blackColor];
enter.alpha = 0.7;
[labelBackground addSubview:enter];
UILabel *secretCode = [[UILabel alloc] initWithFrame:CGRectMake(40, 50, 60, 20)];
[secretCode setBackgroundColor:[UIColor cyanColor]];
secretCode.text = @"密码";
secretCode.textAlignment = NSTextAlignmentCenter;
secretCode.textColor = [UIColor blackColor];
[labelBackground addSubview:secretCode];
UITextField *accountNumber = [[UITextField alloc] initWithFrame:CGRectMake(120, 20, 120, 20)];
[accountNumber setBackgroundColor:[UIColor cyanColor]];
accountNumber.placeholder = @"请输入账号";
accountNumber.textAlignment = NSTextAlignmentCenter;
accountNumber.font = [UIFont systemFontOfSize:15];
accountNumber.borderStyle = UITextBorderStyleRoundedRect;
accountNumber.alpha = 0.7;
[accountNumber setClearsOnBeginEditing:YES];
[labelBackground addSubview:accountNumber];
UITextField *code = [[UITextField alloc] initWithFrame:CGRectMake(120, 50, 120, 20)];
[code setBackgroundColor:[UIColor cyanColor]];
code.placeholder = @"请输入密码";
code.textAlignment = NSTextAlignmentCenter;
code.font = [UIFont systemFontOfSize:15];
code.borderStyle = UITextBorderStyleRoundedRect;
[code setClearsOnBeginEditing:YES];
code.secureTextEntry = YES;
[labelBackground addSubview:code];
UIButton *exit = [UIButton buttonWithType:UIButtonTypeSystem];
[exit setTitle:@"取消" forState:UIControlStateNormal];
[exit setBackgroundColor:[UIColor orangeColor]];
[exit setFrame:CGRectMake(70, 90, 60, 20)];
[labelBackground addSubview:exit];
UIButton *Enter = [UIButton buttonWithType:UIButtonTypeSystem];
[Enter setTitle:@"登录" forState:UIControlStateNormal];
[Enter setBackgroundColor:[UIColor orangeColor]];
[Enter setFrame:CGRectMake(150, 90, 60, 20)];
[labelBackground addSubview:Enter];
[labelBackground release];
[enter release];
[secretCode release];
[code release];