@@ -81,6 +81,7 @@ - (void)slk_commonInit
81
81
self.charCountLabelWarningColor = [UIColor redColor ];
82
82
83
83
self.autoHideRightButton = YES ;
84
+ self.leftButtonIsHidden = YES ;
84
85
self.editorContentViewHeight = 38.0 ;
85
86
self.contentInset = UIEdgeInsetsMake (5.0 , 8.0 , 5.0 , 8.0 );
86
87
@@ -517,6 +518,13 @@ - (void)setCounterPosition:(SLKCounterPosition)counterPosition
517
518
[self addConstraints: self .charCountLabelVCs];
518
519
}
519
520
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
+ }
520
528
521
529
#pragma mark - Text Editing
522
530
@@ -713,8 +721,13 @@ - (void)slk_updateConstraintConstants
713
721
self.leftButtonBottomMarginC .constant = roundf ((self.intrinsicContentSize .height - leftButtonSize.height ) / 2.0 ) + self.slk_contentViewHeight / 2.0 ;
714
722
}
715
723
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
+ }
718
731
719
732
self.rightButtonWC .constant = [self slk_appropriateRightButtonWidth ];
720
733
self.rightMarginWC .constant = [self slk_appropriateRightButtonMargin ];
0 commit comments