I am facing the same question,so I explore the JSQMessagesViewController issues;
The issue 358: said that the author is not going to support this any time soon, because other features have higher priority and no one else has requested this. And the author suggest us to fork and customize it.
The other issue is asking the same question and there is a example using Frame to add a second button.
I don't think it's a good example.
I think my demo below is better.
In the viewDidLoad
method of JSQMessagesViewController
or subclass
UIButton *btn=[UIButton buttonWithType:UIButtonTypeContactAdd];
JSQMessagesToolbarContentView *contentView= self.inputToolbar.contentView;
[contentView.leftBarButtonContainerView addSubview:btn];//add the new button
contentView.leftBarButtonItemWidth=66; //make containerView wider to hold more buttons
//remove unused leftBarButtonItem constraint
for (NSLayoutConstraint *constraint in contentView.leftBarButtonItem.superview.constraints) {
if(constraint.secondItem ==contentView.leftBarButtonItem &&constraint.firstAttribute ==NSLayoutAttributeLeading){
constraint.active=NO;
}
}
// update two button constraint
[contentView.leftBarButtonItem mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(@30);
}];
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(btn.superview.mas_top);
make.bottom.equalTo(btn.superview.mas_bottom);
make.left.equalTo(btn.mas_left);
make.width.equalTo(@30);
}];
Result like this:
InputToolBarContent