将 UITextView backgroundColor 设置为clearColor 使其具有动画效果 - 如何防止这种情况?
我正在以编程方式将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
中设置您的视图
您可以尝试在方法
You can try setting up your view in the
method
这可能是一篇非常老的帖子,但在以编程方式将带有
UITextView
的UIViewController
推送到UINavigationController
上后,我遇到了同样的问题,因为它是 UINavigationController 上的主视图。堆。我在 Swift 2.2 中使用 iOS 8+ API 解决了这个问题,如下所示:
This might be a very old post, but I had the same issue after pushing programmatically a
UIViewController
with anUITextView
as it's main view onto aUINavigationController
stack.I solved this in Swift 2.2 with iOS 8+ API like this: