我只是实例化一个UITextField并注意到文本不是垂直居中的.相反,它与我的按钮顶部齐平,我觉得有点奇怪,因为我希望默认值垂直居中.如何将其垂直居中,或者是否存在我缺少的默认设置?
我正在创建cocoa应用程序,其中我以NSTextField编程方式创建了这样的,
NSView *superView = [[NSView alloc] initWithFrame:NSMakeRect(0, 300, 1400, 500)];
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(180, 100, 1000, 300)];
[myTextField setStringValue:myText];
[myTextField setEditable:NO];
[myTextField setBezeled:NO];
[myTextField setDrawsBackground:NO];
[myTextField setSelectable:NO];
[myTextField setFont:[NSFont fontWithName:@"Futura" size:22]];
[superView addSubview:myTextField];
[superView setAutoresizesSubviews:YES];
[myTextField setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self.window.contentView addSubview:superView];
Run Code Online (Sandbox Code Playgroud)
现在我想要文本的垂直对齐,它应该根据文本长度进行调整.
有人有什么建议吗?请分享你的建议:)
非常感谢..!!