控件宽度 = itemWidth
控件个数 = itemCount
父视图宽度 = width
间距数 spaceCount = itemCount +1
第 i 个 控件与superview左边的距离 = i * itemSpace + (i - 1)*itemWidth
= i * width / (itemCount + 1) - ( i * (itemWidth*itemCount) / (itemCount+1) + (i + 1)*itemWidth )
= i * width / (itemCount + 1) + (i + 1)*itemWidth - i * (itemWidth*itemCount) / (itemCount+1)
总结:
muti = i /spaceCount
constant = (i - 1)*itemWidth - i * itemSumWidth/spaceCount
view.leading = superview.trailing * (i /spaceCount ) + (i - 1)*itemWidth - i * itemSumWidth/spaceCount
例:
控件宽度 = itemWidth = 50
控件个数 = itemCount = 4
muti = 0.2, 0.4, 0.6, 0.8
constant = -40 ,-30 , -20 , -10