0
VFL 제약 조건이 계속 파괴되어 그 이유를 알 수 없습니다. 커스텀 배경을 가진 UIButton입니다. 뷰의 양쪽에서 10 픽셀의 공간을 유지하면서 유연한 너비를 갖기를 원합니다. 여기 코드는 다음과 같습니다ios : 내 vfl 제약 조건이 깨졌습니다.
- (void)viewDidLoad
{
UIImage *buttonImage = [[UIImage imageNamed:@"bluebutton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)];
UIImage *buttonImageHighlight = [[UIImage imageNamed:@"bluebuttonHighlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)];
[[self view] addSubview:[self useLocationButton]];
[[self view] setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *nameMap = @{@"locationbtn":[self useLocationButton],@"mainview":[self view]};
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[locationbtn(>=36)]-10-|"
options:0
metrics:nil
views:nameMap];
[[self view] addConstraints:horizontalConstraints];
[[self useLocationButton] setBackgroundImage:buttonImage forState:UIControlStateNormal];
[[self useLocationButton] setBackgroundImage:buttonImageHighlight forState:UIControlStateHighlighted];
[[self useLocationButton] setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[[self useLocationButton] setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
}