Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
Issue #26 #26

Cell inset 0,0 was not aligning properly
  • Loading branch information
patchthecode committed May 24, 2016
1 parent d5835ff commit ab0921f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 0 additions & 4 deletions Pod/Classes/JTAppleCalendarDelegates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ extension JTAppleCalendarView: UICollectionViewDataSource, UICollectionViewDeleg
restoreSelectionStateForCellAtIndexPath(indexPath)

let dayCell = collectionView.dequeueReusableCellWithReuseIdentifier(cellReuseIdentifier, forIndexPath: indexPath) as! JTAppleDayCell

dayCell.bounds.origin.y = 0
dayCell.bounds.origin.x = 0

let date = dateFromPath(indexPath)!
let cellState = cellStateFromIndexPath(indexPath, withDate: date)

Expand Down
8 changes: 7 additions & 1 deletion Pod/Classes/JTAppleCalendarFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ public class JTAppleCalendarHorizontalFlowLayout: JTAppleCalendarBaseFlowLayout
}

attributes.frame = CGRectMake(xCellOffset, yCellOffset, self.itemSize.width, self.itemSize.height)
attributes.bounds = CGRectMake(0, 0, self.itemSize.width, self.itemSize.height)
if let visibleCell = collectionView.cellForItemAtIndexPath(attributes.indexPath) as? JTAppleDayCell {
// tell the cell to update its contents
visibleCell.updateCellView(visibleCell.cellView)

visibleCell.bounds.origin.y = 0
visibleCell.bounds.origin.x = 0
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Pod/Classes/JTAppleDayCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class JTAppleDayCell: UICollectionViewCell {
return
}

updateCellView(view)
}

func updateCellView(view: JTAppleDayCellView) {
let vFrame = CGRectInset(self.frame, internalCellInset.x, internalCellInset.y)
view.frame = vFrame
view.center = CGPoint(x: self.bounds.size.width * 0.5, y: self.bounds.size.height * 0.5)
Expand Down

0 comments on commit ab0921f

Please sign in to comment.