@@ -81,6 +81,7 @@ - (void)slk_commonInit
8181 self.charCountLabelWarningColor = [UIColor redColor ];
8282
8383 self.autoHideRightButton = YES ;
84+ self.leftButtonIsHidden = YES ;
8485 self.editorContentViewHeight = 38.0 ;
8586 self.contentInset = UIEdgeInsetsMake (5.0 , 8.0 , 5.0 , 8.0 );
8687
@@ -517,6 +518,13 @@ - (void)setCounterPosition:(SLKCounterPosition)counterPosition
517518 [self addConstraints: self .charCountLabelVCs];
518519}
519520
521+ - (void )setLeftButtonHidden : (BOOL )isHidden
522+ {
523+ self.leftButtonIsHidden = isHidden;
524+ CGFloat leftButtonWidth = isHidden ? 0 : [self .rightButton intrinsicContentSize ].width ;
525+ self.leftButton .hidden = isHidden;
526+ self.leftButtonWC .constant = leftButtonWidth;
527+ }
520528
521529#pragma mark - Text Editing
522530
@@ -713,8 +721,13 @@ - (void)slk_updateConstraintConstants
713721 self.leftButtonBottomMarginC .constant = roundf ((self.intrinsicContentSize .height - leftButtonSize.height ) / 2.0 ) + self.slk_contentViewHeight / 2.0 ;
714722 }
715723
716- self.leftButtonWC .constant = roundf (leftButtonSize.width );
717- self.leftMarginWC .constant = (leftButtonSize.width > 0 ) ? self.contentInset .left : zero;
724+ if (self.leftButtonIsHidden ) {
725+ self.leftButtonWC .constant = 0 ;
726+ self.leftMarginWC .constant = zero;
727+ } else {
728+ self.leftButtonWC .constant = roundf (leftButtonSize.width );
729+ self.leftMarginWC .constant = (leftButtonSize.width > 0 ) ? self.contentInset .left : zero;
730+ }
718731
719732 self.rightButtonWC .constant = [self slk_appropriateRightButtonWidth ];
720733 self.rightMarginWC .constant = [self slk_appropriateRightButtonMargin ];
0 commit comments