Skip to content

Commit 8659418

Browse files
author
Vitaliy G
committed
added constraints with ios8 support
1 parent 7af0d26 commit 8659418

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

QMChatViewController/Views/CustomUI/InputToolBar/QMInputToolbar.m

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,9 @@ - (void)toggleButtons {
133133

134134
if (!self.audioRecordButtonItem.superview) {
135135
[self.contentView.rightBarButtonContainerView addSubview:[self audioRecordButtonItem]];
136-
[self audioRecordButtonItem].translatesAutoresizingMaskIntoConstraints = false;
137-
138-
[[[self audioRecordButtonItem].centerXAnchor constraintEqualToAnchor:self.contentView.rightBarButtonContainerView.centerXAnchor] setActive:YES];
139136

140-
[[[self audioRecordButtonItem].centerYAnchor constraintEqualToAnchor:self.contentView.rightBarButtonContainerView.centerYAnchor] setActive:YES];
137+
[self audioRecordButtonItem].translatesAutoresizingMaskIntoConstraints = false;
138+
[self addCenterConstraintsToItem:self.contentView.rightBarButtonContainerView];
141139
}
142140
}
143141
else {
@@ -147,12 +145,33 @@ - (void)toggleButtons {
147145

148146
if (!self.audioRecordButtonItem.superview) {
149147
[self.contentView.leftBarButtonContainerView addSubview:[self audioRecordButtonItem]];
148+
[self audioRecordButtonItem].translatesAutoresizingMaskIntoConstraints = false;
149+
[self addCenterConstraintsToItem:self.contentView.leftBarButtonContainerView];
150150
}
151151
}
152152

153153
self.audioRecordButtonItem.hidden = hasDataToSend;
154154
}
155155

156+
- (void)addCenterConstraintsToItem:(UIView *)itemToAdd {
157+
158+
[[NSLayoutConstraint constraintWithItem:self.audioRecordButtonItem
159+
attribute:NSLayoutAttributeCenterX
160+
relatedBy:NSLayoutRelationEqual
161+
toItem:itemToAdd
162+
attribute:NSLayoutAttributeCenterX
163+
multiplier:1.0f
164+
constant:0.0f] setActive:YES];;
165+
166+
[[NSLayoutConstraint constraintWithItem:self.audioRecordButtonItem
167+
attribute:NSLayoutAttributeCenterY
168+
relatedBy:NSLayoutRelationEqual
169+
toItem:itemToAdd
170+
attribute:NSLayoutAttributeCenterY
171+
multiplier:1.0f
172+
constant:0.0f] setActive:YES];
173+
}
174+
156175
- (void)toggleSendButtonEnabled {
157176

158177
if (self.audioRecordingIsEnabled) {

0 commit comments

Comments
 (0)