@@ -114,6 +114,14 @@ - (NSUInteger)minimumTabWidth
114
114
115
115
- (void )setShowsAddTabButton : (BOOL )showsAddTabButton
116
116
{
117
+ // showsAddTabButton:
118
+ // The trailing constraint is a 5pt margin.
119
+ // !showsAddTabButton:
120
+ // The trailing constraint is a negative margin so the add
121
+ // button is clipped out of the right side of the view. The
122
+ // amount of negative margin is the width of the button plus
123
+ // the 5 to account for the margin between the scroll view
124
+ // and the button.
117
125
if (_showsAddTabButton != showsAddTabButton) {
118
126
_showsAddTabButton = showsAddTabButton;
119
127
_addTabButtonTrailingConstraint.constant = showsAddTabButton ? 5 : -(NSWidth (_addTabButton.frame ) + 5 );;
@@ -122,9 +130,18 @@ - (void)setShowsAddTabButton:(BOOL)showsAddTabButton
122
130
123
131
- (void )setShowsTabScrollButtons : (BOOL )showsTabScrollButtons
124
132
{
133
+ // showsTabScrollButtons:
134
+ // The leading constraint is a 5pt margin.
135
+ // !showsTabScrollButtons:
136
+ // The leading constraint is a negative margin so the scroll
137
+ // buttons are clipped out of the left side of the view. The
138
+ // amount of the negative margin is the width of each button
139
+ // plus 5 to account for the margin between the buttons and
140
+ // the scroll view plus 2 to account for the 2pt shadow inset
141
+ // of each tab (see -drawRect: in MMTab.m).
125
142
if (_showsTabScrollButtons != showsTabScrollButtons) {
126
143
_showsTabScrollButtons = showsTabScrollButtons;
127
- _tabScrollButtonsLeadingConstraint.constant = showsTabScrollButtons ? 5 : -((NSWidth (_leftScrollButton.frame ) * 2 ) + 5 );
144
+ _tabScrollButtonsLeadingConstraint.constant = showsTabScrollButtons ? 5 : -((NSWidth (_leftScrollButton.frame ) * 2 ) + 5 + 2 );
128
145
}
129
146
}
130
147
0 commit comments