123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //
- // ImageCheckRow.swift
- // O2Platform
- //
- // Created by 刘振兴 on 2016/10/2.
- // Copyright © 2016年 zoneland. All rights reserved.
- //
- import Foundation
- import Eureka
- public final class ImageCheckRow<T: Equatable>: Row<ImageCheckCell<T>>, SelectableRowType, RowType {
- public var selectableValue: T?
- required public init(tag: String?) {
- super.init(tag: tag)
- displayValueFor = nil
- }
- }
- public class ImageCheckCell<T: Equatable> : Cell<T>, CellType {
-
- required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
- }
-
- required public init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- lazy public var trueImage: UIImage = {
- return UIImage(named: "selected")!
- }()
-
- lazy public var falseImage: UIImage = {
- return UIImage(named: "unselected")!
- }()
-
- public override func update() {
- super.update()
- accessoryType = .none
- imageView?.image = row.value != nil ? trueImage : falseImage
- }
-
- public override func setup() {
- super.setup()
- }
-
- public override func didSelect() {
- row.reload()
- row.select()
- row.deselect()
- }
-
- }
|