Настройка UITextView clearColor оставляет отпечатки текста при прокрутке - PullRequest
0 голосов
/ 22 октября 2018

Я добавляю UITextView в UIView (parentView), который создается программно.я добавляю textView к этому parentView с помощью вызова addSubView и устанавливаю его backgroundColor в clearColor.

Всякий раз, когда я устанавливаю backgroundColor в clearColor, а затем прокручиваю textView, он прокручивает текст, но оставляет ту же копию теста.

Вот мой код

    -(void) setup
{

    self.headerTextView = [[UITextView alloc] init];
    self.footerTextView = [[UITextView alloc] init];
    self.notificationsImageView = [[UIImageView alloc]initWithImage:
                                   [UIImage imageNamed:@"notifications_bell_icon"]];
    self.titleLabel = [[UILabel alloc] init];

    self.notificationsImageView.translatesAutoresizingMaskIntoConstraints = NO;
    self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;

    self.headerTextView.backgroundColor = UIColor.clearColor;

    self.headerTextView.editable = NO;
    self.footerTextView.editable = NO;

    self.titleLabel.numberOfLines = 0;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;

    [self addSubview:self.titleLabel];
    [self addSubview:self.headerTextView];
    [self addSubview:self.notificationsImageView];

    self.titleLabel.text = @"Test this";


    NSMutableArray<NSLayoutConstraint *> *constraints = [NSMutableArray array];
   [constraints addObject:[self.notificationsImageView.topAnchor constraintEqualToAnchor:self.availableGuide.topAnchor constant:16.0]];
    [constraints addObject:[self.notificationsImageView.widthAnchor constraintEqualToConstant:88.0]];
    [constraints addObject:[self.notificationsImageView.heightAnchor constraintEqualToConstant:88.0]];
    [constraints addObject:[self.notificationsImageView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor constant:0.0]];


    [constraints addObject:[self.titleLabel.topAnchor constraintEqualToAnchor:self.notificationsImageView.bottomAnchor
                                                                     constant:16.0]];
    [constraints addObject:[self.titleLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor]];
    [self.titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [constraints addObject:[self.titleLabel.leadingAnchor constraintEqualToAnchor:self.availableGuide.leadingAnchor
                                                                             constant:16.0]];
    [constraints addObject:[self.titleLabel.trailingAnchor constraintEqualToAnchor:self.availableGuide.trailingAnchor
                                                                              constant:-16.0]];



    [constraints addObject:[self.headerTextView.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:16.0]];

    [constraints addObject:[self.headerTextView.heightAnchor constraintLessThanOrEqualToConstant:200.0]];
    [self.tableView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [constraints addObject:[self.headerTextView.leadingAnchor constraintEqualToAnchor:self.availableGuide.leadingAnchor
                                                      constant:16.0]];
    [constraints addObject:[self.headerTextView.trailingAnchor constraintEqualToAnchor:self.availableGuide.trailingAnchor
                                                       constant:-16.0]];


    [constraints addObject:[self.headerTextView.bottomAnchor constraintEqualToAnchor:self.availableGuide.bottomAnchor]];


    [self.headerTextView setText:@"dvmnbjh kjsdbkjsd kjbsdv kjbdsv kj fa kjvs d jdsg  vdsj vdsj dsbij dgsjdsg  dsik gdsjvds ewgb j ejgew j vwew ef v i fewmn jfwbfweb  rlkjrglk jkbdgrjk kjndgfkjn kjbdfgkj kjbdbkjbdk kjbdfgkjbk jkbdg jg f fwuvvwj fwe jbfwe efwkjhkjew jhwefbkjbewk ijewfbiewbf iubewfiubwefiubef iwefb wefiuewfb wefiubwef wefibwef iweuf wfejhvwefh dvmnbjh kjsdbkjsd kjbsdv kjbdsv kj fa kjvs d jdsg  vdsj vdsj dsbij dgsjdsg  dsik gdsjvds ewgb j ejgew j vwew ef v i fewmn jfwbfweb  rlkjrglk jkbdgrjk kjndgfkjn kjbdfgkj kjbdbkjbdk kjbdfgkjbk jkbdg jg f fwuvvwj fwe jbfwe efwkjhkjew jhwefbkjbewk ijewfbiewbf iubewfiubwefiubef iwefb wefiuewfb wefiubwef wefibwef iweuf wfejhvwefh  ifwev ewfj"];
}

и вот как это выглядит без прокрутки и при прокрутке.

enter image description here enter image description here

setUp Функция - это просто функция в parentView, которая настраивает все.Проблема возникает, если для backgroundColor установлено значение clearColor, а для любого другого цвета, например redColor, он работает нормально

...