0
UIView를 작성하기 위해 UICollectionView의 앵커 제약 조건을 사용해야합니다. 내가 삽입 한 앵커가 모두 정확하지만 widthAncor에 문제가 ... 나는 설명 :Ancor Constraint에서 너비를 UICollectionView 너비로 설정하십시오.
이 내 CollectionView
_monthCollection = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:monthCollectionLayout];
[self addSubview:_monthCollection];
[_monthCollection.topAnchor constraintEqualToAnchor:self.topAnchor constant:65].active = YES;
[_monthCollection.leftAnchor constraintEqualToAnchor:self.leftAnchor constant:2].active = YES;
[_monthCollection.rightAnchor constraintEqualToAnchor:self.rightAnchor constant:0].active = YES;
[_monthCollection.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:0].active = YES;
이 내있는 UIView
UIView *cursor = [[UIView alloc] init];
cursor.backgroundColor = [UIColor colorWithHexString:@"#E66163" setAlpha:.4];
cursor.layer.borderColor = [UIColor colorWithHexString:@"#E66163" setAlpha:1].CGColor;
cursor.layer.borderWidth = 1;
cursor.layer.cornerRadius = 15;
cursor.translatesAutoresizingMaskIntoConstraints = NO;
[_monthCollection addSubview:cursor];
[cursor.topAnchor constraintEqualToAnchor:_monthCollection.topAnchor constant:0].active = YES;
[cursor.leftAnchor constraintEqualToAnchor:_monthCollection.leftAnchor constant:0].active = YES;
[cursor.widthAnchor constraintEqualToConstant:_monthCollection.frame.size.width].active = YES;
[cursor.bottomAnchor constraintEqualToAnchor:_monthCollection.bottomAnchor constant:0].active = YES;
을 추가입니다
내 UIVIEW의 너비가 _monthCollection.frame.size.width/3과 같아야합니다.
모든 방법을 시도했지만 제약이있는 것 같습니다. 아무런 상관이 없습니다. 결과가 없습니다.
그래서 궁금합니다. 앵커 제약?
을 ... 당신이 경우 말해 줄 수 다른 제약 조건도 정확합니까? – kAiN
실제로 무엇을 하려는지는 모르지만 collectionView의 너비와 너비가 1/3 인 "커서"가 있고 collectionView의 왼쪽에 위치하는 것이 목표 인 경우 right –
그래서 didSelectItemAtIndexPath에서 leftAncor를 어떻게 애니 메이팅해야합니까? – kAiN