@@ -50,7 +50,7 @@ exports.init = function (labels, cb) {
50
50
} else if ( OS_IOS ) {
51
51
if ( $ . segCtrlWrapper . width . slice ( - 1 ) === '%' ) {
52
52
calculatedWidth = Ti . Platform . displayCaps . platformWidth * parseInt ( $ . segCtrlWrapper . width ) / 100 ;
53
- console . log ( 'Calculated the width of ' + args . id + ' to be ' + calculatedWidth ) ;
53
+ // console.log('Calculated the width of ' + args.id + ' to be ' + calculatedWidth);
54
54
} else if ( isNaN ( parseInt ( $ . segCtrlWrapper . width ) ) ) {
55
55
// iOS handles rotation, but the wrapper width needs to be calculated to be
56
56
// the smaller of the height or width to avoid layout issues
@@ -69,10 +69,11 @@ exports.init = function (labels, cb) {
69
69
70
70
// make our buttons
71
71
for ( var i = 0 , j = labels . length ; i < j ; i ++ ) {
72
- if ( ! wrapperWidthIsCalculated && i === j - 1 && ! ios8Plus ( ) ) {
72
+ if ( ! wrapperWidthIsCalculated && i === j - 1 && ! onThreeDPDevice ( ) ) {
73
73
// if an explicit width has been set, we need to shrink the last button
74
74
// by 1 or it will be too wide for the container and won't be shown
75
75
btnWidth = ( parseInt ( btnWidth ) - 1 ) ;
76
+
76
77
if ( OS_ANDROID ) {
77
78
btnWidth += 'dp' ;
78
79
}
@@ -97,11 +98,13 @@ exports.init = function (labels, cb) {
97
98
98
99
// add the button dividers, if desired
99
100
if ( args . withDividers ) {
101
+ var left ;
100
102
for ( var i = 0 , j = labels . length - 1 ; i < j ; i ++ ) { // jshint ignore:line
103
+ left = OS_ANDROID ? ( ( parseInt ( btnWidth ) * ( i + 1 ) + 1 ) + 'dp' ) : ( btnWidth * ( i + 1 ) + ( ! onThreeDPDevice ( ) ? 1 : - 1 ) ) ;
101
104
$ . segCtrlWrapper . add ( Ti . UI . createView ( {
102
105
width : OS_ANDROID ? '1dp' : 1 ,
103
106
height : height ,
104
- left : OS_ANDROID ? ( ( parseInt ( btnWidth ) * ( i + 1 ) + 1 ) + 'dp' ) : ( btnWidth * ( i + 1 ) + ( ! ios8Plus ( ) ? 1 : - 1 ) ) ,
107
+ left : left ,
105
108
backgroundColor : selectedButtonColor ,
106
109
zIndex : 10
107
110
} ) ) ;
@@ -232,10 +235,7 @@ exports.enableAllButtons = function () {
232
235
} ;
233
236
234
237
235
- function ios8Plus ( ) {
236
- if ( OS_IOS && parseInt ( Ti . Platform . version . split ( "." ) [ 0 ] ) >= 7 ) {
237
- return true ;
238
- } else {
239
- return false ;
240
- }
238
+ function onThreeDPDevice ( ) {
239
+ //if we are on a 3DP device (6+ or 6s+) we need to slightly adjust the button width
240
+ return OS_IOS && parseInt ( Ti . Platform . displayCaps . logicalDensityFactor ) === 3 ;
241
241
}
0 commit comments