开发者

Setting UITextView backgroundColor to clearColor makes it animate - how to prevent this?

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 you开发者_StackOverflow社区r help.


You can try setting up your view in the

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

method


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()
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜