我PFLoginViewController在我的应用程序中使用下面的代码进行了子类化。在 5S 或 6 设备上,一切正常。但是,在4S或更低的设备上,有些按钮太高,有些太低,以至于你甚至看不到注册按钮。有人可以检查我的框架,看看是否有办法让我做得更好,让它适合所有设备?
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon76x76@2x.png" ]];
self.logInView.logo = logoView; // logo can be any UIView
self.fieldsBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LoginFieldBG.png"]];
UITextView *iprayed = [[UITextView alloc] initWithFrame:CGRectMake(0, 120, 320, 40)];
iprayed.text = @"iPrayed 4 U";
iprayed.textAlignment = NSTextAlignmentCenter;
iprayed.textColor = [UIColor whiteColor];
iprayed.backgroundColor = [UIColor blackColor];
UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:25];
iprayed.font = cellFont;
[self.logInView addSubview:iprayed];
[self.logInView insertSubview:self.fieldsBackground atIndex:1];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CALayer * l = [self.logInView.logo layer];
[l setMasksToBounds:YES];
[l setCornerRadius:40];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor whiteColor] CGColor]];
// Set frame for elements
[self.logInView.dismissButton setFrame:CGRectMake(10.0f, 10.0f, 87.5f, 45.5f)];
[self.logInView.logo setFrame:CGRectMake(120, 40, 80, 80)];
[self.logInView.facebookButton setFrame:CGRectMake(35.0f, 400.0f, 120.0f, 40.0f)];
[self.logInView.twitterButton setFrame:CGRectMake(35.0f+130.0f, 400.0f, 120.0f, 40.0f)];
[self.logInView.signUpButton setFrame:CGRectMake(35.0f, 490.0f, 250.0f, 40.0f)];
[self.logInView.usernameField setFrame:CGRectMake(35.0f, 175.0f, 250.0f, 50.0f)];
[self.logInView.passwordField setFrame:CGRectMake(35.0f, 225.0f, 250.0f, 50.0f)];
[self.fieldsBackground setFrame:CGRectMake(35.0f, 175.0f, 250.0f, 100.0f)];
[self.logInView.passwordForgottenButton setFrame:CGRectMake(0.0f, 200.0f, 35.0f, 40.0f)];
}
iPhone 5S:

iPhone 4S:
