iOS: Table-style TextField for Login Screen?

前端 未结 5 2392
没有蜡笔的小新
没有蜡笔的小新 2021-02-03 10:01

I wanna make a login screen like the one from Facebook\'s app. The part I wanna replicate is the two text fields that when stacked look like a table group. I can\'t figure out h

相关标签:
5条回答
  • 2021-02-03 10:25

    Take the code from here: https://github.com/c99koder/lastfm-iphone

    if you download the code and look into the FirstRunView.xib you will see the same implementation as desired.

    0 讨论(0)
  • 2021-02-03 10:32

    You can take a UITableView and add UITextField as accessoryType for your purpose.

    0 讨论(0)
  • 2021-02-03 10:36

    Ah! I got the answer. It's just art. It's an UIImage that looks like a 2 cell tableview with borderless UITextFields. Why do I never guess it's art?

    0 讨论(0)
  • 2021-02-03 10:40

    you can use the below code.

    //in .h file

    UITextField *loginId; 
    UITextField *password ;
    

    //in .m file

    - (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;
        }
    
    0 讨论(0)
  • 2021-02-03 10:48

    Just use a UIVIew with rounded corners for the background and add the two text fields as sub views.

    0 讨论(0)
提交回复
热议问题