I'm trying to add my UITextField
to a UIView
that is placed in the centre of the table. The UIView
works fine and is positioned correctly. however the UITextField
is in the wrong position and at the bottom left of the screen. Code below:
self.addFriendView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
self.addFriendView.center=self.view.center;
[self.addFriendView setBackgroundColor:[UIColor whiteColor]];
UITextField *nameField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 40)];
nameField.delegate=self;
nameField.center=self.view.center;
nameField.placeholder=@"enter username";
[self.addFriendView addSubview:nameField];
[self.tableView.superview addSubview:self.addFriendView];
When I am placing the UITextField
in the centre of the UIView
do the coordinates need to be inside the UIView
's coordinates or the frames?