I am testing adding autolayout contraints to view programmatically. But it is hiding my view. I am writing code...
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(50.0, 200.0, 600.0, 200.0)];
[testView setBackgroundColor:[UIColor grayColor]];
[self.view addSubview:testView];
[testView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *views = NSDictionaryOfVariableBindings(testView);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-50-[testView(>=600)]-50-|" options:0 metrics:nil views:views]];
Why this hiding my view? Please help me. Thanks.
You haven't given it any constraints in the vertical direction, so a height of 0 points satisfies all the constraints you gave it. Autolayout likes to jump to 0 if you let it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.