将 UITextView backgroundColor 设置为clearColor 使其具有动画效果 - 如何防止这种情况?

发布于 2024-08-25 18:39:17 字数 669 浏览 4 评论 0原文

我正在以编程方式将 UITextView 添加到 UIView 中。 UITextView 从一开始就应该有一个清晰的背景,但背景是从白色到清晰的动画。我该如何阻止这个动画?这是我的代码:

UITextView *localTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 230, 60)];
localTextView.opaque = NO;
localTextView.backgroundColor = [UIColor clearColor];
localTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
localTextView.userInteractionEnabled = NO;
self.textView = localTextView;  
[localTextView release];

textView.text = @"Cras sit amet purus vitae libero venenatis luctus sit amet non urna. Curabitur volutpat adipis cing nulla, in lacinia eros pulvinar vitae.";

[self addSubview:textView];

感谢您的帮助。

I am adding a UITextView to a UIView programatically. The UITextView should have a clear background from the get go, but the background is animating from white to clear. How do I prevent this animation? Here is my code:

UITextView *localTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 230, 60)];
localTextView.opaque = NO;
localTextView.backgroundColor = [UIColor clearColor];
localTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
localTextView.userInteractionEnabled = NO;
self.textView = localTextView;  
[localTextView release];

textView.text = @"Cras sit amet purus vitae libero venenatis luctus sit amet non urna. Curabitur volutpat adipis cing nulla, in lacinia eros pulvinar vitae.";

[self addSubview:textView];

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

网白 2024-09-01 18:39:17

中设置您的视图

-(void)viewWillAppear:(BOOL*)animated;

您可以尝试在方法

You can try setting up your view in the

-(void)viewWillAppear:(BOOL*)animated;

method

终难遇 2024-09-01 18:39:17

这可能是一篇非常老的帖子,但在以编程方式将带有 UITextViewUIViewController 推送到 UINavigationController 上后,我遇到了同样的问题,因为它是 UINavigationController 上的主视图。堆。

我在 Swift 2.2 中使用 iOS 8+ API 解决了这个问题,如下所示:

UIView.performWithoutAnimation {
    textView.backgroundColor = UIColor.clearColor()
}

This might be a very old post, but I had the same issue after pushing programmatically a UIViewController with an UITextView as it's main view onto a UINavigationController stack.

I solved this in Swift 2.2 with iOS 8+ API like this:

UIView.performWithoutAnimation {
    textView.backgroundColor = UIColor.clearColor()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文