scaling and centering UITextFields
I have a loginviewcontroller, with 2 UITextField, username, password, a button and a UIImageView. This should work over a portrait and land开发者_运维技巧scape mode. However in my landscape mode I want to be able to center all of these elements. How do I do this? Also I would need to scale the size of the elements so that it is appropriate.
I tried playing with the springs and it looks totally weird as everything is streched.
You can set the "contentMode" on your views. This will tell the super view how the subviews should be scaled and positioned when redraw or layout happens. You can also manually position and set the textAlignment etc. in the:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
//align in one way
return YES;
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
//align in a different way
return YES;
}
return NO;
}
精彩评论