I am adding scrollView
using constraints and it is working right. But it is showing strange behaviour.
When I am adding frame of scrollView
as [SBV setFrame:CGRectMake(0, 0, scrllView.frame.size.width,1000)];
then its color is clearColor
always no matter what I am givig to it.
Code:
UIScrollView *scrllView=[UIScrollView new];
[scrllView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:scrllView];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:scrllView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:scrllView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:scrllView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:scrllView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
[scrllView setContentSize:CGSizeMake(self.view.frame.size.width, 1000)];
UIView *SBV=[UIView new];
[SBV setTranslatesAutoresizingMaskIntoConstraints:YES];
[SBV setFrame:CGRectMake(0, 0, scrllView.frame.size.width,1000)];
[SBV setBackgroundColor:[UIColor grayColor]];
[scrllView addSubview:SBV];
When I am adding frame of view
as [SBV setFrame:CGRectMake(0, 0,self.view.frame.size.width,1000)];
then its color is same as given my me. Gray in this case