Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical Line #557

Closed
onurays opened this issue Jan 23, 2017 · 4 comments
Closed

Vertical Line #557

onurays opened this issue Jan 23, 2017 · 4 comments

Comments

@onurays
Copy link

onurays commented Jan 23, 2017

  • Device modal and iOS version. iPhone 7 iOS10
  • Xcode version. XCode 8.2
  • FSCalendar version. 2.6.0

Do you have any insight about the vertical gap between views?

image

@FlorianMielke
Copy link

Can you share the appearance settings to reproduce this issue?

@onurays
Copy link
Author

onurays commented Jan 23, 2017

@FlorianMielke thanks your your quick reply.

        calendarView.today = nil
        calendarView.register(DatePickerCalendarCell.self, forCellReuseIdentifier: "cell")
        calendarView.swipeToChooseGesture.isEnabled = true
        calendarView.allowsMultipleSelection = true
        calendarView.clipsToBounds = true
        calendarView.scrollDirection = .vertical
        calendarView.dataSource = self
        calendarView.delegate = self

And Cell configurations:

import Foundation
import UIKit
import FSCalendar

enum SelectionType : Int {
    case none
    case single
    case leftBorder
    case middle
    case rightBorder
}

class DatePickerCalendarCell: FSCalendarCell {
    
    weak var selectionLayer: CAShapeLayer!
    
    var selectionType: SelectionType = .none {
        didSet {
            setNeedsLayout()
        }
    }
    
    required init!(coder aDecoder: NSCoder!) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        let selectionLayer = CAShapeLayer()
        selectionLayer.fillColor = UIColor.black.cgColor
        selectionLayer.actions = ["hidden": NSNull()]
        self.contentView.layer.insertSublayer(selectionLayer, below: self.titleLabel!.layer)
        self.selectionLayer = selectionLayer
        
        self.shapeLayer.isHidden = true
        
        let view = UIView(frame: self.bounds)
        view.backgroundColor = Colors.white
        self.backgroundView = view
        backgroundColor = Colors.white
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.backgroundView?.frame = self.bounds.insetBy(dx: 0, dy: 0)
        self.selectionLayer.frame = self.contentView.bounds
        
        var titleFrame = titleLabel.frame
        titleFrame.origin.y += 3
        titleLabel.frame = titleFrame
        
        self.selectionLayer.isHidden = false
        if selectionType == .middle {
            self.selectionLayer.path = UIBezierPath(rect: self.selectionLayer.bounds).cgPath
            self.selectionLayer.fillColor = Colors.date_picker_middle_day_bg.cgColor
        }
        else if selectionType == .leftBorder {
            self.selectionLayer.path = UIBezierPath(roundedRect: self.selectionLayer.bounds, byRoundingCorners: [.topLeft, .bottomLeft], cornerRadii: CGSize(width: self.selectionLayer.frame.width / 2, height: self.selectionLayer.frame.width / 2)).cgPath
            self.selectionLayer.fillColor = Colors.date_picker_selected_day_bg.cgColor
        }
        else if selectionType == .rightBorder {
            self.selectionLayer.path = UIBezierPath(roundedRect: self.selectionLayer.bounds, byRoundingCorners: [.topRight, .bottomRight], cornerRadii: CGSize(width: self.selectionLayer.frame.width / 2, height: self.selectionLayer.frame.width / 2)).cgPath
            self.selectionLayer.fillColor = Colors.date_picker_selected_day_bg.cgColor
        }
        else if selectionType == .single {
            let diameter: CGFloat = min(self.selectionLayer.frame.height, self.selectionLayer.frame.width)
            self.selectionLayer.path = UIBezierPath(ovalIn: CGRect(x: self.contentView.frame.width / 2 - diameter / 2, y: self.contentView.frame.height / 2 - diameter / 2, width: diameter, height: diameter)).cgPath
            self.selectionLayer.fillColor = Colors.date_picker_selected_day_bg.cgColor
        } else {
            self.selectionLayer.isHidden = true
        }
    }
    
}

image

@WenchaoD
Copy link
Owner

@onurays Have you tried the latest code in master branch?

@onurays
Copy link
Author

onurays commented Jan 24, 2017

Yeay! It is fixed in the latest version. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants