我在我的應用中添加了UITextField
,它應該是300x30,但最終爲600x60。以下是我迄今爲止...在我的應用程序委託:爲什麼這個UITextField比預期的大兩倍?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
OpenGLViewController* controller = [[OpenGLViewController alloc] init];
[self.window setRootViewController:controller];
[self.window addSubview:controller.view];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[self.window makeKeyAndVisible];
return YES;
}
和OpenGLViewController
:
- (void)loadView {
self.view = [[OpenGLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 300, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = @"Search...";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.returnKeyType = UIReturnKeySearch;
textField.delegate = self;
[self.view addSubview:textField];
}
裏面我OpenGlView
的init(我不認爲任何的這種影響大小):
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self setupLayer];
[self setupContext];
[self setupRenderBuffer];
[self setupFrameBuffer];
[self compileShaders];
glViewport(0, 0, frame.size.width, frame.size.height);
}
return self;
}
爲什麼這UITextField
兩倍大,應該是?
出於好奇,如果將其更改爲150X15,它是否會達到您想要的大小? –