miraan / CalendarDateRangePickerViewController

A calendar date range picker view controller in Swift for iOS.
MIT License
139 stars 79 forks source link

fix remove space between two selected date #6

Closed taier closed 4 years ago

taier commented 6 years ago

Fix for https://github.com/miraan/CalendarDateRangePickerViewController/issues/5

The problem was that in cell width calculation

let padding = collectionViewInsets.left + collectionViewInsets.right
let availableWidth = view.frame.width - padding
let itemWidth = availableWidth / CGFloat(itemsPerRow)

For some collectionView sizes itemWidth resolves as non round float, that causes a small visual glitches.

I added a mechanism that would find the closest insets that could satisfy the resolving into a rounded float. Resolving happens with preserving insets ratio like (20/20, 10/30, etc)

guidev commented 6 years ago

+1