gpt4 book ai didi

ios - 为以编程方式绘制的 View 设置颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:08:52 24 4
gpt4 key购买 nike

我正在修复我的 UITextView 以使其不显示在键盘下方,而是将其调整为正确的约束。这可能是一个愚蠢的问题,除了这个愚蠢的问题之外,很可能有一个简单的解决方法,但我需要将当前为黑色的 View 着色为 whiteColor - 看来我是在正确的代码行上消隐以执行此操作。我已经在 Stack Overflow 和 Google 上搜索了一段时间,但我没有找到一行不返回错误的代码。

键盘后面的黑色矩形。 Screenshot

- (void)keyboardDidShow:(NSNotification *)aNotification {
NSDictionary* info = [aNotification userInfo];
CGRect kbRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
kbRect = [[self view] convertRect:kbRect fromView:nil];
CGSize kbSize = kbRect.size;
CGRect aRect = self.view.frame;

/* This should work, but doesn't quite qet the job done */
// UIEdgeInsets insets = self.textView.contentInset;
// insets.bottom = kbSize.height;
// self.textView.contentInset = insets;
//
// insets = self.textView.scrollIndicatorInsets;
// insets.bottom = kbSize.height;
// self.textView.scrollIndicatorInsets = insets;

/* Instead, we just adjust the frame of the uitextview */
aRect.size.height -= kbSize.height + VERTICAL_KEYRBOARD_MARGIN;
self.companyTextField.frame = aRect;

// If active text field is hidden by keyboard, scroll it so it's visible
// Your application might not need or want this behavior.
if (!CGRectContainsPoint(aRect, self.companyTextField.frame.origin) ) {
CGPoint scrollPoint = CGPointMake(0.0, self.companyTextField.frame.origin.y - kbSize.height);
[self.companyTextField setContentOffset:scrollPoint animated:YES];
}
}

最佳答案

假设 self.companyTextField 是您所说的:

self.companyTextField.backgroundColor = [UIColor whiteColor];

如果您谈论的是主视图:

self.view.backgroundColor = [UIColor whiteColor];

关于ios - 为以编程方式绘制的 View 设置颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20695618/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com