Open
Description
I have a graph which is part of my UIView subclass (looks like this):
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupUI];
}
return self;
}
- (void)awakeFromNib {
[super awakeFromNib];
[self setupUI];
}
- (void)setupUI {
// Create AAChartView instance
_aaChartView = [[AAChartView alloc] init];
_aaChartView.scrollEnabled = NO;
_aaChartView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_aaChartView];
// Add constraints to position and size _aaChartView within RBGraphView
NSLayoutConstraint *topConstraint = [_aaChartView.topAnchor constraintEqualToAnchor:self.topAnchor];
NSLayoutConstraint *bottomConstraint = [_aaChartView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor];
NSLayoutConstraint *leadingConstraint = [_aaChartView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor];
NSLayoutConstraint *trailingConstraint = [_aaChartView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor];
[NSLayoutConstraint activateConstraints:@[topConstraint, bottomConstraint, leadingConstraint, trailingConstraint]];
AAChart *aaChart = AAChart.new
.backgroundColorSet(@"#191923");
AATitle *aaTitle = AATitle.new
.textSet(@"");
AAOptions *aaaOptions = AAOptions.new
.chartSet(aaChart)
.titleSet(aaTitle) ;
[_aaChartView aa_drawChartWithOptions:aaaOptions];
}
It is added to ViewController in viewDidLoad:
public override func viewDidLoad() {
super.viewDidLoad()
rbGraphView = RBGraphView()
guard let rbGraphView = rbGraphView else {return}
rbGraphView.translatesAutoresizingMaskIntoConstraints = false
graphContentView.addSubview(rbGraphView)
// some auto layout constraints
}
The problem is that background color change is happening when the screen is shown, so it flashes from white to #191923
I can't add and draw it earlier then viewDidLoad.
Is there any way to make it earlier?
Metadata
Metadata
Assignees
Labels
No labels