Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Example/IGColorPicker/SquareColorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SquareColorPickerViewController: UIViewController, ColorPickerViewDelegate
// Setup color picker
colorPickerView.delegate = self
colorPickerView.layoutDelegate = self
colorPickerView.isSelectedColorTappable = false
colorPickerView.isSelectedColorTappable = true
colorPickerView.style = .square
colorPickerView.selectionStyle = .check
colorPickerView.backgroundColor = .clear
Expand All @@ -38,9 +38,14 @@ class SquareColorPickerViewController: UIViewController, ColorPickerViewDelegate
// MARK: - ColorPickerViewDelegate

func colorPickerView(_ colorPickerView: ColorPickerView, didSelectItemAt indexPath: IndexPath) {
print("select index \(indexPath.item)")

self.view.backgroundColor = colorPickerView.colors[indexPath.item]
}

func colorPickerView(_ colorPickerView: ColorPickerView, didDeselectItemAt indexPath: IndexPath) {
print("deselect index \(indexPath.item)")
}

// MARK: - ColorPickerViewDelegateFlowLayout

Expand Down
2 changes: 1 addition & 1 deletion IGColorPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ s.ios.deployment_target = '8.0'

s.source_files = 'IGColorPicker/Classes/**/*'

s.dependency 'M13Checkbox', '~> 2.2.0'
s.dependency 'M13Checkbox', '~> 3.2.1'
end
6 changes: 6 additions & 0 deletions IGColorPicker/Classes/View/ColorPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ open class ColorPickerView: UIView, UICollectionViewDelegate, UICollectionViewDa
if let index = preselectedIndex {

guard index >= 0, colors.indices.contains(index) else {
if _indexOfSelectedColor != nil {
_indexOfSelectedColor = nil
collectionView.reloadData()
}

print("ERROR ColorPickerView - preselectedItem out of colors range")
return
}
Expand Down Expand Up @@ -129,6 +134,7 @@ open class ColorPickerView: UIView, UICollectionViewDelegate, UICollectionViewDa
if isSelectedColorTappable {
_indexOfSelectedColor = nil
colorPickerCell.checkbox.setCheckState(.unchecked, animated: animated)
delegate?.colorPickerView?(self, didDeselectItemAt: indexPath)
}
return
}
Expand Down