iOS:用于login屏幕的表格式TextField?
我想做一个像Facebook应用程序的login屏幕。 我想要复制的部分是两个文本字段,当堆叠看起来像一个表组。 我不知道他们是如何做到的。
谁知道这个诀窍?
我不能张贴图片,因为我是新的stackoverflow。 这是一个效果,他们看起来像一个圆形的椭圆形,但内有2个文本字段。 一个用于用户名,一个用于密码。
你可以使用下面的代码。
//在.h文件中
UITextField *loginId; UITextField *password ;
//在.m文件中
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 2; } - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"]; if( cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease]; if (indexPath.row == 0) { loginId = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; loginId .placeholder = @"loginid"; loginId .autocorrectionType = UITextAutocorrectionTypeNo; [loginId setClearButtonMode:UITextFieldViewModeWhileEditing]; cell.accessoryView = loginId ; } if (indexPath.row == 1) { password = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; password.placeholder = @"Password"; password.secureTextEntry = YES; password.autocorrectionType = UITextAutocorrectionTypeNo; [password setClearButtonMode:UITextFieldViewModeWhileEditing]; cell.accessoryView = password; } loginId.delegate = self; password.delegate = self; [tableView1 addSubview:loginId]; [tableView1 addSubview:password]; [loginId release]; [password release]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; }
从这里获取代码: https : //github.com/c99koder/lastfm-iphone
如果您下载代码并查看FirstRunView.xib,您将看到与所需相同的实现。
啊! 我得到了答案。 这只是艺术。 这是一个UIImage,它看起来像带有无边界UITextField的2单元格tableview。 为什么我从来不猜这是艺术?
只需使用带圆angular的UIVIew作为背景,并将两个文本字段添加为子视图即可。
您可以采取一个UITableView
并添加UITextField
作为accessoryType
为您的目的。
- 显示一次login屏幕w /故事板的最佳做法
- 用google plus在parse.com上的ios上login
- Google SignIn SFSafariViewController / WebView在接受权限后redirect到Google.com
- 使用FB SDK v3.5在“允许这些应用程序使用您的帐户”列表中不显示iOS应用程序
- 使用GIDSignIn.sharedInstance.clientID =时的错误代码
- iOS:使用Facebook和Google,Google Pluslogin
- Google Sign-In Error -4
- titaniumiOS – Facebook SSO不返回到应用程序
- 不是使用UIWebView(iOS)自动login到Google+的?