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

2 Date Segment on 1 UIView #92

Closed
mrjimoy opened this issue Jul 28, 2016 · 6 comments
Closed

2 Date Segment on 1 UIView #92

mrjimoy opened this issue Jul 28, 2016 · 6 comments
Assignees
Labels

Comments

@mrjimoy
Copy link

mrjimoy commented Jul 28, 2016

Hi, can I show 2 segment using JTAppleCalendar? I mean, on a UIViewController, I would like to have 2 months displayed vertically instead of only 1.. Please see image below.

image

Thank you.

@patchthecode
Copy link
Owner

patchthecode commented Jul 28, 2016

Let me know if this works for you.

@mrjimoy
Copy link
Author

mrjimoy commented Jul 29, 2016

Hi @patchthecode, thank you so much. It's worked with some adjustment on the measurement. I have another questions:

  1. How to show the day name above the date? Do we need to create a separate XIB (HeaderViewCell) or is there any function that can directly show the day name?
  2. Is it possible to create the multiple selection as a range (like attached image below)? I think this one is related to Manipulating another cell #54, I tried to do some changes on the code but got stuck.

image

Thanks.

@mecid
Copy link

mecid commented Jul 29, 2016

@mrjimoy You need to create separate XIB or add View like this.

class WeekdaysView: UIStackView {
    private lazy var weekdayLabels: [UILabel] = self.createWeekdayLabels()

    private func createWeekdayLabels() -> [UILabel] {
        let formatter = NSDateFormatter()
        var weekdayLabels = [UILabel]()

        for i in 0...6 {
            let label = UILabel(frame: CGRectZero)
            label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption2)
            label.text = formatter.veryShortWeekdaySymbols[i]
            label.textColor = UIColor.lightTextColor()
            label.textAlignment = .Center

            weekdayLabels.append(label)
        }

        return weekdayLabels
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        setup()
    }

    private func setup() {
        self.axis = .Horizontal
        self.alignment = .Center
        self.distribution = .FillEqually

        for label in weekdayLabels {
            addArrangedSubview(label)
        }
    }
}

@patchthecode patchthecode self-assigned this Jul 29, 2016
@patchthecode
Copy link
Owner

patchthecode commented Jul 29, 2016

@mrjimoy

  1. How to show the day name above the date?

Are you trying to make your calendar look like the image you just provided above? If yes, then you can do exactly what @mecid said.

Simply create a header.xib file and design it like this:

screen shot 2016-07-29 at 9 45 13 am

You can look at the example code attached to this project to see how to create a header view. You can also checkout this wiki question

  1. Is it possible to create the multiple selection as a range

Although I do not have this feature built in, the calendar is flexible enough that you can build it your self as can be seen here. It does not take much code to build it, but I will be implementing this as a feature in the library soon.

@patchthecode
Copy link
Owner

i'll close this issue. If you have any other questions please as it on another thread. This thread is now becoming more than one topic.

@mrjimoy
Copy link
Author

mrjimoy commented Aug 1, 2016

Great, thank you so much @patchthecode :)

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

No branches or pull requests

3 participants